/* message_row.c generated by valac 0.56.19, the Vala compiler
 * generated from message_row.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-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
#include <stdio.h>
#include <adwaita.h>
#include <gobject/gvaluecollector.h>

#define DC_MESSAGE_ROW_ALIGN_LEFT 0
#define DC_MESSAGE_ROW_ALIGN_RIGHT 1
#define DC_MESSAGE_ROW_ALIGN_CENTER 2
#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_SCALED_PREVIEW_FRAME (dc_scaled_preview_frame_get_type ())
#define DC_SCALED_PREVIEW_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_SCALED_PREVIEW_FRAME, DcScaledPreviewFrame))
#define DC_SCALED_PREVIEW_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_SCALED_PREVIEW_FRAME, DcScaledPreviewFrameClass))
#define DC_IS_SCALED_PREVIEW_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_SCALED_PREVIEW_FRAME))
#define DC_IS_SCALED_PREVIEW_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_SCALED_PREVIEW_FRAME))
#define DC_SCALED_PREVIEW_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_SCALED_PREVIEW_FRAME, DcScaledPreviewFrameClass))

typedef struct _DcScaledPreviewFrame DcScaledPreviewFrame;
typedef struct _DcScaledPreviewFrameClass DcScaledPreviewFrameClass;
typedef struct _DcScaledPreviewFramePrivate DcScaledPreviewFramePrivate;
enum  {
	DC_SCALED_PREVIEW_FRAME_0_PROPERTY,
	DC_SCALED_PREVIEW_FRAME_CHILD_PROPERTY,
	DC_SCALED_PREVIEW_FRAME_NUM_PROPERTIES
};
static GParamSpec* dc_scaled_preview_frame_properties[DC_SCALED_PREVIEW_FRAME_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define DC_TYPE_MESSAGE_ROW (dc_message_row_get_type ())
#define DC_MESSAGE_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_MESSAGE_ROW, DcMessageRow))
#define DC_MESSAGE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_MESSAGE_ROW, DcMessageRowClass))
#define DC_IS_MESSAGE_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_MESSAGE_ROW))
#define DC_IS_MESSAGE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_MESSAGE_ROW))
#define DC_MESSAGE_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_MESSAGE_ROW, DcMessageRowClass))

typedef struct _DcMessageRow DcMessageRow;
typedef struct _DcMessageRowClass DcMessageRowClass;
typedef struct _DcMessageRowPrivate DcMessageRowPrivate;
enum  {
	DC_MESSAGE_ROW_0_PROPERTY,
	DC_MESSAGE_ROW_MESSAGE_ID_PROPERTY,
	DC_MESSAGE_ROW_IS_OUTGOING_PROPERTY,
	DC_MESSAGE_ROW_NUM_PROPERTIES
};
static GParamSpec* dc_message_row_properties[DC_MESSAGE_ROW_NUM_PROPERTIES];
typedef enum  {
	DC_MESSAGE_STYLE_BUBBLES = 0,
	DC_MESSAGE_STYLE_IRC = 1
} DcMessageStyle;

#define DC_TYPE_MESSAGE_STYLE (dc_message_style_get_type ())

#define DC_TYPE_MESSAGE (dc_message_get_type ())
#define DC_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_MESSAGE, DcMessage))
#define DC_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_MESSAGE, DcMessageClass))
#define DC_IS_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_MESSAGE))
#define DC_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_MESSAGE))
#define DC_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_MESSAGE, DcMessageClass))

typedef struct _DcMessage DcMessage;
typedef struct _DcMessageClass DcMessageClass;
typedef enum  {
	DC_BUBBLE_AVATAR_DISPLAY_NONE = 0,
	DC_BUBBLE_AVATAR_DISPLAY_OTHER = 1,
	DC_BUBBLE_AVATAR_DISPLAY_BOTH = 2
} DcBubbleAvatarDisplay;

#define DC_TYPE_BUBBLE_AVATAR_DISPLAY (dc_bubble_avatar_display_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block18Data Block18Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define DC_TYPE_AUDIO_PLAYER (dc_audio_player_get_type ())
#define DC_AUDIO_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_AUDIO_PLAYER, DcAudioPlayer))
#define DC_AUDIO_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_AUDIO_PLAYER, DcAudioPlayerClass))
#define DC_IS_AUDIO_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_AUDIO_PLAYER))
#define DC_IS_AUDIO_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_AUDIO_PLAYER))
#define DC_AUDIO_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_AUDIO_PLAYER, DcAudioPlayerClass))

typedef struct _DcAudioPlayer DcAudioPlayer;
typedef struct _DcAudioPlayerClass DcAudioPlayerClass;
typedef struct _Block19Data Block19Data;
typedef struct _Block20Data Block20Data;
#define _pango_attr_list_unref0(var) ((var == NULL) ? NULL : (var = (pango_attr_list_unref (var), NULL)))
typedef struct _Block21Data Block21Data;

#define DC_TYPE_WINDOW (dc_window_get_type ())
#define DC_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_WINDOW, DcWindow))
#define DC_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_WINDOW, DcWindowClass))
#define DC_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_WINDOW))
#define DC_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_WINDOW))
#define DC_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_WINDOW, DcWindowClass))

typedef struct _DcWindow DcWindow;
typedef struct _DcWindowClass DcWindowClass;

#define DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK (dc_message_row_markdown_table_block_get_type ())
#define DC_MESSAGE_ROW_MARKDOWN_TABLE_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK, DcMessageRowMarkdownTableBlock))
#define DC_MESSAGE_ROW_MARKDOWN_TABLE_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK, DcMessageRowMarkdownTableBlockClass))
#define DC_MESSAGE_ROW_IS_MARKDOWN_TABLE_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK))
#define DC_MESSAGE_ROW_IS_MARKDOWN_TABLE_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK))
#define DC_MESSAGE_ROW_MARKDOWN_TABLE_BLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK, DcMessageRowMarkdownTableBlockClass))

typedef struct _DcMessageRowMarkdownTableBlock DcMessageRowMarkdownTableBlock;
typedef struct _DcMessageRowMarkdownTableBlockClass DcMessageRowMarkdownTableBlockClass;
#define _dc_message_row_markdown_table_block_unref0(var) ((var == NULL) ? NULL : (var = (dc_message_row_markdown_table_block_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
typedef struct _DcMessageRowMarkdownTableBlockPrivate DcMessageRowMarkdownTableBlockPrivate;

#define DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW (dc_message_row_markdown_table_row_get_type ())
#define DC_MESSAGE_ROW_MARKDOWN_TABLE_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW, DcMessageRowMarkdownTableRow))
#define DC_MESSAGE_ROW_MARKDOWN_TABLE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW, DcMessageRowMarkdownTableRowClass))
#define DC_MESSAGE_ROW_IS_MARKDOWN_TABLE_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW))
#define DC_MESSAGE_ROW_IS_MARKDOWN_TABLE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW))
#define DC_MESSAGE_ROW_MARKDOWN_TABLE_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW, DcMessageRowMarkdownTableRowClass))

typedef struct _DcMessageRowMarkdownTableRow DcMessageRowMarkdownTableRow;
typedef struct _DcMessageRowMarkdownTableRowClass DcMessageRowMarkdownTableRowClass;
typedef struct _DcMessageRowMarkdownTableRowPrivate DcMessageRowMarkdownTableRowPrivate;
#define _dc_message_row_markdown_table_row_unref0(var) ((var == NULL) ? NULL : (var = (dc_message_row_markdown_table_row_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
typedef struct _DcMessageRowParamSpecMarkdownTableRow DcMessageRowParamSpecMarkdownTableRow;
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
typedef struct _DcMessageRowParamSpecMarkdownTableBlock DcMessageRowParamSpecMarkdownTableBlock;
enum  {
	DC_MESSAGE_ROW_QUOTE_CLICKED_SIGNAL,
	DC_MESSAGE_ROW_FULL_MESSAGE_REQUESTED_SIGNAL,
	DC_MESSAGE_ROW_SELECTION_TOGGLED_SIGNAL,
	DC_MESSAGE_ROW_NUM_SIGNALS
};
static guint dc_message_row_signals[DC_MESSAGE_ROW_NUM_SIGNALS] = {0};

struct _DcScaledPreviewFrame {
	GtkWidget parent_instance;
	DcScaledPreviewFramePrivate * priv;
};

struct _DcScaledPreviewFrameClass {
	GtkWidgetClass parent_class;
};

struct _DcScaledPreviewFramePrivate {
	gint natural_width;
	gint natural_height;
	GtkWidget* _child;
};

struct _DcMessageRow {
	GtkBox parent_instance;
	DcMessageRowPrivate * priv;
};

struct _DcMessageRowClass {
	GtkBoxClass parent_class;
};

struct _DcMessageRowPrivate {
	gint _message_id;
	gboolean _is_outgoing;
};

struct _Block18Data {
	int _ref_count_;
	DcMessageRow* self;
	GtkCheckButton* check;
	DcMessage* msg;
};

struct _Block19Data {
	int _ref_count_;
	DcMessageRow* self;
	gint qid;
};

struct _Block20Data {
	int _ref_count_;
	DcMessageRow* self;
	DcMessage* msg;
};

struct _Block21Data {
	int _ref_count_;
	GtkLabel* text;
};

struct _DcMessageRowMarkdownTableBlock {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DcMessageRowMarkdownTableBlockPrivate * priv;
	GPtrArray* rows;
	gint* aligns;
	gint aligns_length1;
	gint _aligns_size_;
};

struct _DcMessageRowMarkdownTableBlockClass {
	GTypeClass parent_class;
	void (*finalize) (DcMessageRowMarkdownTableBlock *self);
};

struct _DcMessageRowMarkdownTableRow {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DcMessageRowMarkdownTableRowPrivate * priv;
	gchar** cells;
	gint cells_length1;
	gint _cells_size_;
	gboolean header;
};

struct _DcMessageRowMarkdownTableRowClass {
	GTypeClass parent_class;
	void (*finalize) (DcMessageRowMarkdownTableRow *self);
};

struct _DcMessageRowParamSpecMarkdownTableRow {
	GParamSpec parent_instance;
};

struct _DcMessageRowParamSpecMarkdownTableBlock {
	GParamSpec parent_instance;
};

static gint DcScaledPreviewFrame_private_offset;
static gpointer dc_scaled_preview_frame_parent_class = NULL;
static gint DcMessageRow_private_offset;
static gpointer dc_message_row_parent_class = NULL;
VALA_EXTERN DcMessageStyle dc_message_row_style;
DcMessageStyle dc_message_row_style = DC_MESSAGE_STYLE_BUBBLES;
VALA_EXTERN gchar* dc_message_row_self_display_name;
gchar* dc_message_row_self_display_name = NULL;
VALA_EXTERN gchar* dc_message_row_self_avatar_path;
gchar* dc_message_row_self_avatar_path = NULL;
static gdouble dc_message_row_media_scale;
static gdouble dc_message_row_media_scale = 1.0;
VALA_EXTERN gboolean dc_markdown_enabled;
static gpointer dc_message_row_markdown_table_row_parent_class = NULL;
static gpointer dc_message_row_markdown_table_block_parent_class = NULL;

VALA_EXTERN GType dc_scaled_preview_frame_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcScaledPreviewFrame, g_object_unref)
VALA_EXTERN DcScaledPreviewFrame* dc_scaled_preview_frame_new (gint natural_width,
                                                   gint natural_height,
                                                   const gchar* css_class);
VALA_EXTERN DcScaledPreviewFrame* dc_scaled_preview_frame_construct (GType object_type,
                                                         gint natural_width,
                                                         gint natural_height,
                                                         const gchar* css_class);
static void dc_scaled_preview_frame_real_dispose (GObject* base);
static GtkSizeRequestMode dc_scaled_preview_frame_real_get_request_mode (GtkWidget* base);
static void dc_scaled_preview_frame_real_measure (GtkWidget* base,
                                           GtkOrientation orientation,
                                           gint for_size,
                                           gint* minimum,
                                           gint* natural,
                                           gint* minimum_baseline,
                                           gint* natural_baseline);
VALA_EXTERN gint dc_message_row_media_size (gint value);
static void dc_scaled_preview_frame_real_size_allocate (GtkWidget* base,
                                                 gint width,
                                                 gint height,
                                                 gint baseline);
static void dc_scaled_preview_frame_real_snapshot (GtkWidget* base,
                                            GtkSnapshot* snapshot);
VALA_EXTERN GtkWidget* dc_scaled_preview_frame_get_child (DcScaledPreviewFrame* self);
VALA_EXTERN void dc_scaled_preview_frame_set_child (DcScaledPreviewFrame* self,
                                        GtkWidget* value);
static void dc_scaled_preview_frame_finalize (GObject * obj);
static GType dc_scaled_preview_frame_get_type_once (void);
static void _vala_dc_scaled_preview_frame_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_dc_scaled_preview_frame_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec);
VALA_EXTERN GType dc_message_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessageRow, g_object_unref)
VALA_EXTERN GType dc_message_style_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void dc_message_row_set_media_scale (gint font_size,
                                     gint system_font_size);
VALA_EXTERN void dc_message_row_highlight (DcMessageRow* self);
static gboolean __lambda68_ (DcMessageRow* self);
static gboolean ___lambda68__gsource_func (gpointer self);
VALA_EXTERN gboolean dc_message_row_has_selectable_text (DcMessageRow* self);
static gboolean dc_message_row_has_selectable_text_in (GtkWidget* widget);
VALA_EXTERN gboolean dc_message_row_select_all_text (DcMessageRow* self);
static void dc_message_row_select_all_text_in (GtkWidget* widget,
                                        gboolean* selected,
                                        gboolean* focused);
VALA_EXTERN GType dc_message_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessage, g_object_unref)
VALA_EXTERN GType dc_bubble_avatar_display_get_type (void) G_GNUC_CONST ;
VALA_EXTERN DcMessageRow* dc_message_row_new (DcMessage* msg,
                                  DcMessage* prev,
                                  GPtrArray* trailing_images,
                                  gboolean is_image_continuation,
                                  DcBubbleAvatarDisplay avatar_display,
                                  gboolean avatar_scope_enabled,
                                  gboolean show_sender_name);
VALA_EXTERN DcMessageRow* dc_message_row_construct (GType object_type,
                                        DcMessage* msg,
                                        DcMessage* prev,
                                        GPtrArray* trailing_images,
                                        gboolean is_image_continuation,
                                        DcBubbleAvatarDisplay avatar_display,
                                        gboolean avatar_scope_enabled,
                                        gboolean show_sender_name);
VALA_EXTERN gint dc_message_get_id (DcMessage* self);
static void dc_message_row_set_message_id (DcMessageRow* self,
                                    gint value);
VALA_EXTERN gboolean dc_message_get_is_outgoing (DcMessage* self);
static void dc_message_row_set_is_outgoing (DcMessageRow* self,
                                     gboolean value);
static void dc_message_row_build_irc_row (DcMessageRow* self,
                                   DcMessage* msg,
                                   DcMessage* prev,
                                   GPtrArray* trailing_images,
                                   gboolean is_image_continuation);
static void dc_message_row_append_selection_checkbox (DcMessageRow* self,
                                               DcMessage* msg);
VALA_EXTERN gboolean dc_message_get_is_info (DcMessage* self);
static void dc_message_row_build_info_row (DcMessageRow* self,
                                    DcMessage* msg);
static gboolean dc_message_row_should_show_bubble_avatar (DcMessage* msg,
                                                   DcBubbleAvatarDisplay display,
                                                   gboolean scope_enabled);
VALA_EXTERN gboolean dc_message_get_is_forwarded (DcMessage* self);
static GtkLabel* dc_message_row_build_forwarded_indicator (DcMessage* msg);
static gchar* dc_message_row_effective_author_name (DcMessage* msg);
VALA_EXTERN const gchar* dc_message_get_sender_address (DcMessage* self);
VALA_EXTERN const gchar* dc_message_get_quote_text (DcMessage* self);
static GtkButton* dc_message_row_build_quote_block (DcMessageRow* self,
                                             DcMessage* msg,
                                             gint max_width_chars,
                                             gint lines);
static void dc_message_row_append_attachment (DcMessageRow* self,
                                       GtkBox* box,
                                       DcMessage* msg,
                                       gboolean irc,
                                       GPtrArray* trailing_images);
VALA_EXTERN const gchar* dc_message_get_text (DcMessage* self);
static GtkWidget* dc_message_row_build_text_widget (DcMessageRow* self,
                                             DcMessage* msg,
                                             gint max_width_chars);
VALA_EXTERN gboolean dc_message_get_is_edited (DcMessage* self);
static GtkLabel* dc_message_row_build_edited_indicator (const gchar* text);
static gchar* dc_message_row_format_timestamp (gint64 ts);
VALA_EXTERN gint64 dc_message_get_timestamp (DcMessage* self);
static GtkLabel* dc_message_row_build_tick_indicator (DcMessage* msg);
static GtkLabel* dc_message_row_build_pin_indicator (DcMessage* msg);
static GtkBox* dc_message_row_build_reactions_box (DcMessage* msg);
static GtkWidget* dc_message_row_build_bubble_avatar (DcMessage* msg);
static gchar* dc_message_row_effective_sender_name (DcMessage* msg);
static Block18Data* block18_data_ref (Block18Data* _data18_);
static void block18_data_unref (void * _userdata_);
static void __lambda77_ (Block18Data* _data18_);
VALA_EXTERN gboolean dc_message_get_selected (DcMessage* self);
VALA_EXTERN void dc_message_set_selected (DcMessage* self,
                              gboolean value);
static void ___lambda77__gtk_check_button_toggled (GtkCheckButton* _sender,
                                            gpointer self);
VALA_EXTERN gboolean dc_message_get_has_file (DcMessage* self);
VALA_EXTERN gboolean dc_message_get_has_local_file (DcMessage* self);
VALA_EXTERN gboolean dc_message_is_image_file (DcMessage* self);
static void dc_message_row_append_irc_images (GtkBox* body,
                                       DcMessage* msg,
                                       GPtrArray* trailing_images);
static void dc_message_row_append_bubble_image (GtkBox* bubble,
                                         DcMessage* msg);
VALA_EXTERN gboolean dc_message_is_video_file (DcMessage* self);
static GtkWidget* dc_message_row_build_video_preview (DcMessage* msg);
VALA_EXTERN gboolean dc_message_is_audio_file (DcMessage* self);
static GtkWidget* dc_message_row_build_audio_player (DcMessage* msg);
static GtkBox* dc_message_row_build_file_indicator (DcMessage* msg);
VALA_EXTERN const gchar* dc_message_get_sender_name (DcMessage* self);
VALA_EXTERN const gchar* dc_message_get_sender_avatar_path (DcMessage* self);
VALA_EXTERN GtkWidget* dc_presence_avatar (gint size,
                               const gchar* text,
                               const gchar* path,
                               gboolean online,
                               const gchar* avatar_css,
                               const gchar* ring_css);
static GtkWidget* dc_message_row_load_picture (const gchar* path,
                                        gint max_w,
                                        gint max_h,
                                        gint min_w,
                                        gint min_h);
VALA_EXTERN const gchar* dc_message_get_file_path (DcMessage* self);
static void dc_message_row_append_irc_image (GtkBox* strip,
                                      DcMessage* m);
VALA_EXTERN gchar* dc_message_display_file_name (DcMessage* self,
                                     const gchar* fallback);
static void dc_message_row_fit_size (gint* dw,
                              gint* dh,
                              gint max_w,
                              gint max_h,
                              gint min_w,
                              gint min_h);
VALA_EXTERN GdkTexture* dc_texture_from_pixbuf (GdkPixbuf* pixbuf);
VALA_EXTERN gboolean dc_message_row_same_irc_sender (DcMessage* a,
                                         DcMessage* b);
VALA_EXTERN const gchar* dc_message_get_override_sender_name (DcMessage* self);
static GtkWidget* dc_message_row_build_video_paintable (DcMessage* msg);
VALA_EXTERN const gchar* dc_message_get_file_name (DcMessage* self);
VALA_EXTERN DcAudioPlayer* dc_audio_player_new (const gchar* path,
                                    const gchar* name);
VALA_EXTERN DcAudioPlayer* dc_audio_player_construct (GType object_type,
                                          const gchar* path,
                                          const gchar* name);
VALA_EXTERN GType dc_audio_player_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcAudioPlayer, g_object_unref)
VALA_EXTERN gboolean dc_message_get_is_failed (DcMessage* self);
VALA_EXTERN gboolean dc_message_get_is_read (DcMessage* self);
VALA_EXTERN gboolean dc_message_get_is_delivered (DcMessage* self);
VALA_EXTERN gboolean dc_message_get_is_pending (DcMessage* self);
VALA_EXTERN gint dc_message_get_quote_msg_id (DcMessage* self);
static Block19Data* block19_data_ref (Block19Data* _data19_);
static void block19_data_unref (void * _userdata_);
static void ___lambda69_ (Block19Data* _data19_);
static void ____lambda69__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN const gchar* dc_message_get_quote_sender_name (DcMessage* self);
static Block20Data* block20_data_ref (Block20Data* _data20_);
static void block20_data_unref (void * _userdata_);
static GtkWidget* dc_message_row_build_text_with_tables (const gchar* raw,
                                                  gint max_width_chars);
static GtkLabel* dc_message_row_build_markup_label (const gchar* raw,
                                             gint max_width_chars,
                                             gboolean big_emoji);
static gboolean dc_message_row_is_single_emoji_text (const gchar* raw);
VALA_EXTERN gboolean dc_message_get_has_full_message_action (DcMessage* self);
VALA_EXTERN gboolean dc_message_get_is_downloading_full_message (DcMessage* self);
VALA_EXTERN gboolean dc_message_get_can_download_full_message (DcMessage* self);
static void ___lambda76_ (Block20Data* _data20_);
static void ____lambda76__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN gchar* dc_markdown_format (const gchar* input);
static void dc_message_row_connect_label_links (GtkLabel* text);
static Block21Data* block21_data_ref (Block21Data* _data21_);
static void block21_data_unref (void * _userdata_);
static gboolean __lambda70_ (Block21Data* _data21_,
                      const gchar* uri);
VALA_EXTERN gboolean dc_is_delta_invite_uri (const gchar* uri);
VALA_EXTERN GType dc_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcWindow, g_object_unref)
VALA_EXTERN void dc_window_handle_invite_uri (DcWindow* self,
                                  const gchar* uri);
static gboolean ___lambda70__gtk_label_activate_link (GtkLabel* _sender,
                                               const gchar* uri,
                                               gpointer self);
static gboolean dc_message_row_is_code_fence_line (const gchar* line);
static gpointer dc_message_row_markdown_table_block_ref (gpointer instance);
static void dc_message_row_markdown_table_block_unref (gpointer instance);
static GParamSpec* dc_message_row_param_spec_markdown_table_block (const gchar* name,
                                                            const gchar* nick,
                                                            const gchar* blurb,
                                                            GType object_type,
                                                            GParamFlags flags) G_GNUC_UNUSED ;
static void dc_message_row_value_set_markdown_table_block (GValue* value,
                                                    gpointer v_object) G_GNUC_UNUSED ;
static void dc_message_row_value_take_markdown_table_block (GValue* value,
                                                     gpointer v_object) G_GNUC_UNUSED ;
static gpointer dc_message_row_value_get_markdown_table_block (const GValue* value) G_GNUC_UNUSED ;
static GType dc_message_row_markdown_table_block_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessageRowMarkdownTableBlock, dc_message_row_markdown_table_block_unref)
static DcMessageRowMarkdownTableBlock* dc_message_row_parse_table_at (gchar** lines,
                                                               gint lines_length1,
                                                               gint start,
                                                               gint* end);
static void dc_message_row_append_text_block (GtkBox* body,
                                       gchar** lines,
                                       gint lines_length1,
                                       gint start,
                                       gint end,
                                       gint max_width_chars);
static GtkWidget* dc_message_row_build_table_grid (DcMessageRowMarkdownTableBlock* table,
                                            gint max_width_chars);
static gchar* dc_message_row_join_lines (gchar** lines,
                                  gint lines_length1,
                                  gint start,
                                  gint end);
static gchar** dc_message_row_parse_table_row (const gchar* line,
                                        gint* result_length1);
static gboolean dc_message_row_is_table_separator (gchar** cells,
                                            gint cells_length1);
static DcMessageRowMarkdownTableBlock* dc_message_row_markdown_table_block_new (gint columns);
static DcMessageRowMarkdownTableBlock* dc_message_row_markdown_table_block_construct (GType object_type,
                                                                               gint columns);
static gpointer dc_message_row_markdown_table_row_ref (gpointer instance);
static void dc_message_row_markdown_table_row_unref (gpointer instance);
static GParamSpec* dc_message_row_param_spec_markdown_table_row (const gchar* name,
                                                          const gchar* nick,
                                                          const gchar* blurb,
                                                          GType object_type,
                                                          GParamFlags flags) G_GNUC_UNUSED ;
static void dc_message_row_value_set_markdown_table_row (GValue* value,
                                                  gpointer v_object) G_GNUC_UNUSED ;
static void dc_message_row_value_take_markdown_table_row (GValue* value,
                                                   gpointer v_object) G_GNUC_UNUSED ;
static gpointer dc_message_row_value_get_markdown_table_row (const GValue* value) G_GNUC_UNUSED ;
static GType dc_message_row_markdown_table_row_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessageRowMarkdownTableRow, dc_message_row_markdown_table_row_unref)
static gint dc_message_row_table_separator_align (const gchar* cell);
static DcMessageRowMarkdownTableRow* dc_message_row_markdown_table_row_new (gchar** cells,
                                                                     gint cells_length1,
                                                                     gboolean header);
static DcMessageRowMarkdownTableRow* dc_message_row_markdown_table_row_construct (GType object_type,
                                                                           gchar** cells,
                                                                           gint cells_length1,
                                                                           gboolean header);
static gint dc_message_row_table_cell_width_chars (gint columns,
                                            gint max_width_chars);
static GtkWidget* dc_message_row_build_table_cell (const gchar* raw,
                                            gint width_chars,
                                            gint align,
                                            gboolean header);
static gboolean dc_message_row_consume_emoji_sequence (const gchar* text,
                                                gint* index);
static gboolean dc_message_row_is_keycap_base (gunichar c);
static gboolean dc_message_row_consume_variation_selectors (const gchar* text,
                                                     gint* index);
static gboolean dc_message_row_consume_char (const gchar* text,
                                      gint* index,
                                      gunichar expected);
static gboolean dc_message_row_is_regional_indicator (gunichar c);
static gboolean dc_message_row_is_emoji_base (gunichar c);
static void dc_message_row_consume_emoji_modifiers (const gchar* text,
                                             gint* index);
static gboolean dc_message_row_consume_emoji_modifier (const gchar* text,
                                                gint* index);
static void dc_message_row_consume_tag_sequence (const gchar* text,
                                          gint* index);
VALA_EXTERN const gchar* dc_message_get_reactions (DcMessage* self);
VALA_EXTERN GtkWidget* dc_message_row_build_date_separator (gint64 ts);
VALA_EXTERN gchar* dc_message_row_format_date_label (gint64 ts);
VALA_EXTERN gboolean dc_message_row_same_day (gint64 ts1,
                                  gint64 ts2);
VALA_EXTERN gint dc_message_row_get_message_id (DcMessageRow* self);
VALA_EXTERN gboolean dc_message_row_get_is_outgoing (DcMessageRow* self);
static void g_cclosure_user_marshal_VOID__INT_BOOLEAN (GClosure * closure,
                                                GValue * return_value,
                                                guint n_param_values,
                                                const GValue * param_values,
                                                gpointer invocation_hint,
                                                gpointer marshal_data);
static gchar** _vala_array_dup3 (gchar** self,
                          gssize length);
static void dc_message_row_markdown_table_row_finalize (DcMessageRowMarkdownTableRow * obj);
static GType dc_message_row_markdown_table_row_get_type_once (void);
static void _dc_message_row_markdown_table_row_unref0_ (gpointer var);
static void dc_message_row_markdown_table_block_finalize (DcMessageRowMarkdownTableBlock * obj);
static GType dc_message_row_markdown_table_block_get_type_once (void);
static void dc_message_row_finalize (GObject * obj);
static GType dc_message_row_get_type_once (void);
static void _vala_dc_message_row_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
static void _vala_dc_message_row_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GRegex* _tmp_regex_0 = NULL;

static inline gpointer
dc_scaled_preview_frame_get_instance_private (DcScaledPreviewFrame* self)
{
	return G_STRUCT_MEMBER_P (self, DcScaledPreviewFrame_private_offset);
}

DcScaledPreviewFrame*
dc_scaled_preview_frame_construct (GType object_type,
                                   gint natural_width,
                                   gint natural_height,
                                   const gchar* css_class)
{
	DcScaledPreviewFrame * self = NULL;
	self = (DcScaledPreviewFrame*) g_object_new (object_type, NULL);
	self->priv->natural_width = MAX (1, natural_width);
	self->priv->natural_height = MAX (1, natural_height);
	gtk_widget_set_overflow ((GtkWidget*) self, GTK_OVERFLOW_HIDDEN);
	if (css_class != NULL) {
		gtk_widget_add_css_class ((GtkWidget*) self, css_class);
	}
	return self;
}

DcScaledPreviewFrame*
dc_scaled_preview_frame_new (gint natural_width,
                             gint natural_height,
                             const gchar* css_class)
{
	return dc_scaled_preview_frame_construct (DC_TYPE_SCALED_PREVIEW_FRAME, natural_width, natural_height, css_class);
}

static void
dc_scaled_preview_frame_real_dispose (GObject* base)
{
	DcScaledPreviewFrame * self;
	GtkWidget* _tmp0_;
	self = (DcScaledPreviewFrame*) base;
	_tmp0_ = self->priv->_child;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = self->priv->_child;
		gtk_widget_unparent (_tmp1_);
		_g_object_unref0 (self->priv->_child);
		self->priv->_child = NULL;
	}
	G_OBJECT_CLASS (dc_scaled_preview_frame_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
}

static GtkSizeRequestMode
dc_scaled_preview_frame_real_get_request_mode (GtkWidget* base)
{
	DcScaledPreviewFrame * self;
	GtkSizeRequestMode result;
	self = (DcScaledPreviewFrame*) base;
	result = GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
	return result;
}

static void
dc_scaled_preview_frame_real_measure (GtkWidget* base,
                                      GtkOrientation orientation,
                                      gint for_size,
                                      gint* minimum,
                                      gint* natural,
                                      gint* minimum_baseline,
                                      gint* natural_baseline)
{
	DcScaledPreviewFrame * self;
	gint _vala_minimum = 0;
	gint _vala_natural = 0;
	gint _vala_minimum_baseline = 0;
	gint _vala_natural_baseline = 0;
	gint width = 0;
	gint height = 0;
	self = (DcScaledPreviewFrame*) base;
	_vala_natural_baseline = -1;
	_vala_minimum_baseline = _vala_natural_baseline;
	width = dc_message_row_media_size (self->priv->natural_width);
	height = dc_message_row_media_size (self->priv->natural_height);
	if (orientation == GTK_ORIENTATION_HORIZONTAL) {
		_vala_minimum = 1;
		_vala_natural = width;
		if (minimum) {
			*minimum = _vala_minimum;
		}
		if (natural) {
			*natural = _vala_natural;
		}
		if (minimum_baseline) {
			*minimum_baseline = _vala_minimum_baseline;
		}
		if (natural_baseline) {
			*natural_baseline = _vala_natural_baseline;
		}
		return;
	}
	if (for_size > 0) {
		gint allocated_width = 0;
		gint h = 0;
		allocated_width = MIN (for_size, width);
		h = MAX (1, (gint) (((((gint64) height) * allocated_width) + (width / 2)) / width));
		_vala_natural = h;
		_vala_minimum = _vala_natural;
	} else {
		_vala_minimum = 1;
		_vala_natural = height;
	}
	if (minimum) {
		*minimum = _vala_minimum;
	}
	if (natural) {
		*natural = _vala_natural;
	}
	if (minimum_baseline) {
		*minimum_baseline = _vala_minimum_baseline;
	}
	if (natural_baseline) {
		*natural_baseline = _vala_natural_baseline;
	}
}

static void
dc_scaled_preview_frame_real_size_allocate (GtkWidget* base,
                                            gint width,
                                            gint height,
                                            gint baseline)
{
	DcScaledPreviewFrame * self;
	GtkWidget* _tmp0_;
	self = (DcScaledPreviewFrame*) base;
	_tmp0_ = self->priv->_child;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = self->priv->_child;
		gtk_widget_allocate (_tmp1_, width, height, baseline, NULL);
	}
}

static void
dc_scaled_preview_frame_real_snapshot (GtkWidget* base,
                                       GtkSnapshot* snapshot)
{
	DcScaledPreviewFrame * self;
	GtkWidget* _tmp0_;
	self = (DcScaledPreviewFrame*) base;
	g_return_if_fail (snapshot != NULL);
	_tmp0_ = self->priv->_child;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = self->priv->_child;
		gtk_widget_snapshot_child ((GtkWidget*) self, _tmp1_, snapshot);
	}
}

GtkWidget*
dc_scaled_preview_frame_get_child (DcScaledPreviewFrame* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_child;
	result = _tmp0_;
	return result;
}

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

void
dc_scaled_preview_frame_set_child (DcScaledPreviewFrame* self,
                                   GtkWidget* value)
{
	GtkWidget* _tmp0_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_child;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = self->priv->_child;
		gtk_widget_unparent (_tmp1_);
	}
	_tmp2_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_child);
	self->priv->_child = _tmp2_;
	_tmp3_ = self->priv->_child;
	if (_tmp3_ != NULL) {
		GtkWidget* _tmp4_;
		_tmp4_ = self->priv->_child;
		gtk_widget_set_parent (_tmp4_, (GtkWidget*) self);
	}
	gtk_widget_queue_resize ((GtkWidget*) self);
	g_object_notify_by_pspec ((GObject *) self, dc_scaled_preview_frame_properties[DC_SCALED_PREVIEW_FRAME_CHILD_PROPERTY]);
}

static void
dc_scaled_preview_frame_class_init (DcScaledPreviewFrameClass * klass,
                                    gpointer klass_data)
{
	dc_scaled_preview_frame_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcScaledPreviewFrame_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) dc_scaled_preview_frame_real_dispose;
	((GtkWidgetClass *) klass)->get_request_mode = (GtkSizeRequestMode (*) (GtkWidget*)) dc_scaled_preview_frame_real_get_request_mode;
	((GtkWidgetClass *) klass)->measure = (void (*) (GtkWidget*, GtkOrientation, gint, gint*, gint*, gint*, gint*)) dc_scaled_preview_frame_real_measure;
	((GtkWidgetClass *) klass)->size_allocate = (void (*) (GtkWidget*, gint, gint, gint)) dc_scaled_preview_frame_real_size_allocate;
	((GtkWidgetClass *) klass)->snapshot = (void (*) (GtkWidget*, GtkSnapshot*)) dc_scaled_preview_frame_real_snapshot;
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_scaled_preview_frame_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_scaled_preview_frame_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_scaled_preview_frame_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_SCALED_PREVIEW_FRAME_CHILD_PROPERTY, dc_scaled_preview_frame_properties[DC_SCALED_PREVIEW_FRAME_CHILD_PROPERTY] = g_param_spec_object ("child", "child", "child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
dc_scaled_preview_frame_instance_init (DcScaledPreviewFrame * self,
                                       gpointer klass)
{
	self->priv = dc_scaled_preview_frame_get_instance_private (self);
	self->priv->_child = NULL;
}

static void
dc_scaled_preview_frame_finalize (GObject * obj)
{
	DcScaledPreviewFrame * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_SCALED_PREVIEW_FRAME, DcScaledPreviewFrame);
	_g_object_unref0 (self->priv->_child);
	G_OBJECT_CLASS (dc_scaled_preview_frame_parent_class)->finalize (obj);
}

static GType
dc_scaled_preview_frame_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcScaledPreviewFrameClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_scaled_preview_frame_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcScaledPreviewFrame), 0, (GInstanceInitFunc) dc_scaled_preview_frame_instance_init, NULL };
	GType dc_scaled_preview_frame_type_id;
	dc_scaled_preview_frame_type_id = g_type_register_static (gtk_widget_get_type (), "DcScaledPreviewFrame", &g_define_type_info, 0);
	DcScaledPreviewFrame_private_offset = g_type_add_instance_private (dc_scaled_preview_frame_type_id, sizeof (DcScaledPreviewFramePrivate));
	return dc_scaled_preview_frame_type_id;
}

GType
dc_scaled_preview_frame_get_type (void)
{
	static volatile gsize dc_scaled_preview_frame_type_id__once = 0;
	if (g_once_init_enter (&dc_scaled_preview_frame_type_id__once)) {
		GType dc_scaled_preview_frame_type_id;
		dc_scaled_preview_frame_type_id = dc_scaled_preview_frame_get_type_once ();
		g_once_init_leave (&dc_scaled_preview_frame_type_id__once, dc_scaled_preview_frame_type_id);
	}
	return dc_scaled_preview_frame_type_id__once;
}

static void
_vala_dc_scaled_preview_frame_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	DcScaledPreviewFrame * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_SCALED_PREVIEW_FRAME, DcScaledPreviewFrame);
	switch (property_id) {
		case DC_SCALED_PREVIEW_FRAME_CHILD_PROPERTY:
		g_value_set_object (value, dc_scaled_preview_frame_get_child (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_scaled_preview_frame_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	DcScaledPreviewFrame * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_SCALED_PREVIEW_FRAME, DcScaledPreviewFrame);
	switch (property_id) {
		case DC_SCALED_PREVIEW_FRAME_CHILD_PROPERTY:
		dc_scaled_preview_frame_set_child (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
dc_message_row_get_instance_private (DcMessageRow* self)
{
	return G_STRUCT_MEMBER_P (self, DcMessageRow_private_offset);
}

void
dc_message_row_set_media_scale (gint font_size,
                                gint system_font_size)
{
	gdouble _tmp0_ = 0.0;
	gboolean _tmp1_ = FALSE;
	if (font_size > 0) {
		_tmp1_ = system_font_size > 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = ((gdouble) font_size) / ((gdouble) system_font_size);
	} else {
		_tmp0_ = 1.0;
	}
	dc_message_row_media_scale = _tmp0_;
}

gint
dc_message_row_media_size (gint value)
{
	gint result;
	result = MAX (1, (gint) ((value * dc_message_row_media_scale) + 0.5));
	return result;
}

static gboolean
__lambda68_ (DcMessageRow* self)
{
	gboolean result;
	gtk_widget_remove_css_class ((GtkWidget*) self, "message-new");
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda68__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda68_ ((DcMessageRow*) self);
	return result;
}

void
dc_message_row_highlight (DcMessageRow* self)
{
	g_return_if_fail (self != NULL);
	gtk_widget_add_css_class ((GtkWidget*) self, "message-new");
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 2000, ___lambda68__gsource_func, g_object_ref (self), g_object_unref);
}

gboolean
dc_message_row_has_selectable_text (DcMessageRow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = dc_message_row_has_selectable_text_in ((GtkWidget*) self);
	return result;
}

gboolean
dc_message_row_select_all_text (DcMessageRow* self)
{
	gboolean selected = FALSE;
	gboolean focused = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	selected = FALSE;
	focused = FALSE;
	dc_message_row_select_all_text_in ((GtkWidget*) self, &selected, &focused);
	result = selected;
	return result;
}

static gboolean
dc_message_row_has_selectable_text_in (GtkWidget* widget)
{
	GtkLabel* label = NULL;
	GtkLabel* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	GtkLabel* _tmp3_;
	gboolean result;
	if (widget == NULL) {
		result = FALSE;
		return result;
	}
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_label_get_type ()) ? ((GtkLabel*) widget) : NULL);
	label = _tmp0_;
	_tmp3_ = label;
	if (_tmp3_ != NULL) {
		GtkLabel* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = label;
		_tmp5_ = gtk_label_get_selectable (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp2_ = _tmp6_;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		GtkLabel* _tmp7_;
		const gchar* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		_tmp7_ = label;
		_tmp8_ = gtk_label_get_text (_tmp7_);
		_tmp9_ = strlen (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp1_ = _tmp10_ > 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		result = TRUE;
		_g_object_unref0 (label);
		return result;
	}
	{
		GtkWidget* child = NULL;
		GtkWidget* _tmp11_;
		GtkWidget* _tmp12_;
		_tmp11_ = gtk_widget_get_first_child (widget);
		_tmp12_ = _g_object_ref0 (_tmp11_);
		child = _tmp12_;
		{
			gboolean _tmp13_ = FALSE;
			_tmp13_ = TRUE;
			while (TRUE) {
				GtkWidget* _tmp17_;
				GtkWidget* _tmp18_;
				if (!_tmp13_) {
					GtkWidget* _tmp14_;
					GtkWidget* _tmp15_;
					GtkWidget* _tmp16_;
					_tmp14_ = child;
					_tmp15_ = gtk_widget_get_next_sibling (_tmp14_);
					_tmp16_ = _g_object_ref0 (_tmp15_);
					_g_object_unref0 (child);
					child = _tmp16_;
				}
				_tmp13_ = FALSE;
				_tmp17_ = child;
				if (!(_tmp17_ != NULL)) {
					break;
				}
				_tmp18_ = child;
				if (dc_message_row_has_selectable_text_in (_tmp18_)) {
					result = TRUE;
					_g_object_unref0 (child);
					_g_object_unref0 (label);
					return result;
				}
			}
		}
		_g_object_unref0 (child);
	}
	result = FALSE;
	_g_object_unref0 (label);
	return result;
}

static void
dc_message_row_select_all_text_in (GtkWidget* widget,
                                   gboolean* selected,
                                   gboolean* focused)
{
	GtkLabel* label = NULL;
	GtkLabel* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	GtkLabel* _tmp3_;
	if (widget == NULL) {
		return;
	}
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_label_get_type ()) ? ((GtkLabel*) widget) : NULL);
	label = _tmp0_;
	_tmp3_ = label;
	if (_tmp3_ != NULL) {
		GtkLabel* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = label;
		_tmp5_ = gtk_label_get_selectable (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp2_ = _tmp6_;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		GtkLabel* _tmp7_;
		const gchar* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		_tmp7_ = label;
		_tmp8_ = gtk_label_get_text (_tmp7_);
		_tmp9_ = strlen (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp1_ = _tmp10_ > 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GtkLabel* _tmp12_;
		if (!(*focused)) {
			GtkLabel* _tmp11_;
			_tmp11_ = label;
			gtk_widget_grab_focus ((GtkWidget*) _tmp11_);
			*focused = TRUE;
		}
		_tmp12_ = label;
		gtk_label_select_region (_tmp12_, 0, -1);
		*selected = TRUE;
	}
	{
		GtkWidget* child = NULL;
		GtkWidget* _tmp13_;
		GtkWidget* _tmp14_;
		_tmp13_ = gtk_widget_get_first_child (widget);
		_tmp14_ = _g_object_ref0 (_tmp13_);
		child = _tmp14_;
		{
			gboolean _tmp15_ = FALSE;
			_tmp15_ = TRUE;
			while (TRUE) {
				GtkWidget* _tmp19_;
				GtkWidget* _tmp20_;
				if (!_tmp15_) {
					GtkWidget* _tmp16_;
					GtkWidget* _tmp17_;
					GtkWidget* _tmp18_;
					_tmp16_ = child;
					_tmp17_ = gtk_widget_get_next_sibling (_tmp16_);
					_tmp18_ = _g_object_ref0 (_tmp17_);
					_g_object_unref0 (child);
					child = _tmp18_;
				}
				_tmp15_ = FALSE;
				_tmp19_ = child;
				if (!(_tmp19_ != NULL)) {
					break;
				}
				_tmp20_ = child;
				dc_message_row_select_all_text_in (_tmp20_, selected, focused);
			}
		}
		_g_object_unref0 (child);
	}
	_g_object_unref0 (label);
}

DcMessageRow*
dc_message_row_construct (GType object_type,
                          DcMessage* msg,
                          DcMessage* prev,
                          GPtrArray* trailing_images,
                          gboolean is_image_continuation,
                          DcBubbleAvatarDisplay avatar_display,
                          gboolean avatar_scope_enabled,
                          gboolean show_sender_name)
{
	DcMessageRow * self = NULL;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_;
	gboolean _tmp6_;
	gboolean outgoing = FALSE;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gboolean show_avatar = FALSE;
	GtkBox* bubble = NULL;
	GtkBox* _tmp9_;
	GtkBox* _tmp10_;
	const gchar* _tmp11_ = NULL;
	GtkBox* _tmp12_;
	GtkBox* _tmp13_;
	gboolean _tmp14_;
	gboolean _tmp15_;
	gboolean _tmp40_ = FALSE;
	const gchar* _tmp41_;
	const gchar* _tmp42_;
	GtkBox* _tmp50_;
	gboolean _tmp51_ = FALSE;
	const gchar* _tmp52_;
	const gchar* _tmp53_;
	GtkBox* footer = NULL;
	GtkBox* _tmp61_;
	GtkBox* _tmp62_;
	gboolean _tmp63_;
	gboolean _tmp64_;
	gchar* time_str = NULL;
	gint64 _tmp68_;
	gint64 _tmp69_;
	gchar* _tmp70_;
	GtkLabel* time_lbl = NULL;
	const gchar* _tmp71_;
	GtkLabel* _tmp72_;
	GtkLabel* _tmp73_;
	GtkBox* _tmp74_;
	GtkLabel* _tmp75_;
	GtkBox* _tmp80_;
	GtkLabel* _tmp81_;
	GtkLabel* _tmp82_;
	GtkBox* _tmp83_;
	GtkBox* _tmp84_;
	GtkBox* reactions_box = NULL;
	GtkBox* _tmp85_;
	GtkBox* _tmp86_;
	gboolean _tmp92_ = FALSE;
	GtkBox* _tmp95_;
	gboolean _tmp96_ = FALSE;
	g_return_val_if_fail (msg != NULL, NULL);
	self = (DcMessageRow*) g_object_new (object_type, "orientation", GTK_ORIENTATION_HORIZONTAL, "spacing", 0, NULL);
	_tmp0_ = dc_message_get_id (msg);
	_tmp1_ = _tmp0_;
	dc_message_row_set_message_id (self, _tmp1_);
	_tmp2_ = dc_message_get_is_outgoing (msg);
	_tmp3_ = _tmp2_;
	dc_message_row_set_is_outgoing (self, _tmp3_);
	gtk_widget_set_hexpand ((GtkWidget*) self, TRUE);
	gtk_widget_set_halign ((GtkWidget*) self, GTK_ALIGN_FILL);
	if (dc_message_row_style == DC_MESSAGE_STYLE_IRC) {
		_tmp4_ = is_image_continuation;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		dc_message_row_build_irc_row (self, msg, prev, trailing_images, is_image_continuation);
		return self;
	}
	dc_message_row_append_selection_checkbox (self, msg);
	_tmp5_ = dc_message_get_is_info (msg);
	_tmp6_ = _tmp5_;
	if (_tmp6_) {
		dc_message_row_build_info_row (self, msg);
		return self;
	}
	if (dc_message_row_style == DC_MESSAGE_STYLE_IRC) {
		dc_message_row_build_irc_row (self, msg, prev, trailing_images, is_image_continuation);
		return self;
	}
	_tmp7_ = dc_message_get_is_outgoing (msg);
	_tmp8_ = _tmp7_;
	outgoing = _tmp8_;
	show_avatar = dc_message_row_should_show_bubble_avatar (msg, avatar_display, avatar_scope_enabled);
	gtk_widget_set_margin_start ((GtkWidget*) self, 8);
	gtk_widget_set_margin_end ((GtkWidget*) self, 8);
	gtk_widget_set_margin_top ((GtkWidget*) self, 2);
	gtk_widget_set_margin_bottom ((GtkWidget*) self, 2);
	_tmp9_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
	g_object_ref_sink (_tmp9_);
	bubble = _tmp9_;
	_tmp10_ = bubble;
	gtk_widget_add_css_class ((GtkWidget*) _tmp10_, "message-bubble");
	if (outgoing) {
		_tmp11_ = "outgoing";
	} else {
		_tmp11_ = "incoming";
	}
	_tmp12_ = bubble;
	gtk_widget_add_css_class ((GtkWidget*) _tmp12_, _tmp11_);
	_tmp13_ = bubble;
	gtk_widget_set_valign ((GtkWidget*) _tmp13_, GTK_ALIGN_START);
	_tmp14_ = dc_message_get_is_forwarded (msg);
	_tmp15_ = _tmp14_;
	if (_tmp15_) {
		GtkBox* _tmp16_;
		GtkLabel* _tmp17_;
		GtkLabel* _tmp18_;
		_tmp16_ = bubble;
		_tmp17_ = dc_message_row_build_forwarded_indicator (msg);
		_tmp18_ = _tmp17_;
		gtk_box_append (_tmp16_, (GtkWidget*) _tmp18_);
		_g_object_unref0 (_tmp18_);
	} else {
		gboolean _tmp19_ = FALSE;
		if (!outgoing) {
			_tmp19_ = show_sender_name;
		} else {
			_tmp19_ = FALSE;
		}
		if (_tmp19_) {
			gchar* author = NULL;
			gchar* _tmp20_;
			const gchar* _tmp21_;
			_tmp20_ = dc_message_row_effective_author_name (msg);
			author = _tmp20_;
			_tmp21_ = author;
			if (_tmp21_ != NULL) {
				GtkLabel* sender = NULL;
				const gchar* _tmp22_;
				GtkLabel* _tmp23_;
				GtkLabel* _tmp24_;
				GtkLabel* _tmp25_;
				GtkLabel* _tmp26_;
				GtkLabel* _tmp27_;
				gboolean _tmp28_ = FALSE;
				const gchar* _tmp29_;
				const gchar* _tmp30_;
				GtkBox* _tmp38_;
				GtkLabel* _tmp39_;
				_tmp22_ = author;
				_tmp23_ = (GtkLabel*) gtk_label_new (_tmp22_);
				g_object_ref_sink (_tmp23_);
				sender = _tmp23_;
				_tmp24_ = sender;
				gtk_widget_add_css_class ((GtkWidget*) _tmp24_, "message-sender");
				_tmp25_ = sender;
				gtk_widget_set_halign ((GtkWidget*) _tmp25_, GTK_ALIGN_START);
				_tmp26_ = sender;
				gtk_label_set_xalign (_tmp26_, (gfloat) 0);
				_tmp27_ = sender;
				gtk_label_set_ellipsize (_tmp27_, PANGO_ELLIPSIZE_END);
				_tmp29_ = dc_message_get_sender_address (msg);
				_tmp30_ = _tmp29_;
				if (_tmp30_ != NULL) {
					const gchar* _tmp31_;
					const gchar* _tmp32_;
					gint _tmp33_;
					gint _tmp34_;
					_tmp31_ = dc_message_get_sender_address (msg);
					_tmp32_ = _tmp31_;
					_tmp33_ = strlen (_tmp32_);
					_tmp34_ = _tmp33_;
					_tmp28_ = _tmp34_ > 0;
				} else {
					_tmp28_ = FALSE;
				}
				if (_tmp28_) {
					GtkLabel* _tmp35_;
					const gchar* _tmp36_;
					const gchar* _tmp37_;
					_tmp35_ = sender;
					_tmp36_ = dc_message_get_sender_address (msg);
					_tmp37_ = _tmp36_;
					gtk_widget_set_tooltip_text ((GtkWidget*) _tmp35_, _tmp37_);
				}
				_tmp38_ = bubble;
				_tmp39_ = sender;
				gtk_box_append (_tmp38_, (GtkWidget*) _tmp39_);
				_g_object_unref0 (sender);
			}
			_g_free0 (author);
		}
	}
	_tmp41_ = dc_message_get_quote_text (msg);
	_tmp42_ = _tmp41_;
	if (_tmp42_ != NULL) {
		const gchar* _tmp43_;
		const gchar* _tmp44_;
		gint _tmp45_;
		gint _tmp46_;
		_tmp43_ = dc_message_get_quote_text (msg);
		_tmp44_ = _tmp43_;
		_tmp45_ = strlen (_tmp44_);
		_tmp46_ = _tmp45_;
		_tmp40_ = _tmp46_ > 0;
	} else {
		_tmp40_ = FALSE;
	}
	if (_tmp40_) {
		GtkBox* _tmp47_;
		GtkButton* _tmp48_;
		GtkButton* _tmp49_;
		_tmp47_ = bubble;
		_tmp48_ = dc_message_row_build_quote_block (self, msg, 40, 2);
		_tmp49_ = _tmp48_;
		gtk_box_append (_tmp47_, (GtkWidget*) _tmp49_);
		_g_object_unref0 (_tmp49_);
	}
	_tmp50_ = bubble;
	dc_message_row_append_attachment (self, _tmp50_, msg, FALSE, NULL);
	_tmp52_ = dc_message_get_text (msg);
	_tmp53_ = _tmp52_;
	if (_tmp53_ != NULL) {
		const gchar* _tmp54_;
		const gchar* _tmp55_;
		gint _tmp56_;
		gint _tmp57_;
		_tmp54_ = dc_message_get_text (msg);
		_tmp55_ = _tmp54_;
		_tmp56_ = strlen (_tmp55_);
		_tmp57_ = _tmp56_;
		_tmp51_ = _tmp57_ > 0;
	} else {
		_tmp51_ = FALSE;
	}
	if (_tmp51_) {
		GtkBox* _tmp58_;
		GtkWidget* _tmp59_;
		GtkWidget* _tmp60_;
		_tmp58_ = bubble;
		_tmp59_ = dc_message_row_build_text_widget (self, msg, 50);
		_tmp60_ = _tmp59_;
		gtk_box_append (_tmp58_, _tmp60_);
		_g_object_unref0 (_tmp60_);
	}
	_tmp61_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
	g_object_ref_sink (_tmp61_);
	footer = _tmp61_;
	_tmp62_ = footer;
	gtk_widget_set_halign ((GtkWidget*) _tmp62_, GTK_ALIGN_END);
	_tmp63_ = dc_message_get_is_edited (msg);
	_tmp64_ = _tmp63_;
	if (_tmp64_) {
		GtkBox* _tmp65_;
		GtkLabel* _tmp66_;
		GtkLabel* _tmp67_;
		_tmp65_ = footer;
		_tmp66_ = dc_message_row_build_edited_indicator ("Edited");
		_tmp67_ = _tmp66_;
		gtk_box_append (_tmp65_, (GtkWidget*) _tmp67_);
		_g_object_unref0 (_tmp67_);
	}
	_tmp68_ = dc_message_get_timestamp (msg);
	_tmp69_ = _tmp68_;
	_tmp70_ = dc_message_row_format_timestamp (_tmp69_);
	time_str = _tmp70_;
	_tmp71_ = time_str;
	_tmp72_ = (GtkLabel*) gtk_label_new (_tmp71_);
	g_object_ref_sink (_tmp72_);
	time_lbl = _tmp72_;
	_tmp73_ = time_lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp73_, "message-time");
	_tmp74_ = footer;
	_tmp75_ = time_lbl;
	gtk_box_append (_tmp74_, (GtkWidget*) _tmp75_);
	if (outgoing) {
		GtkLabel* tick = NULL;
		GtkLabel* _tmp76_;
		GtkLabel* _tmp77_;
		_tmp76_ = dc_message_row_build_tick_indicator (msg);
		tick = _tmp76_;
		_tmp77_ = tick;
		if (_tmp77_ != NULL) {
			GtkBox* _tmp78_;
			GtkLabel* _tmp79_;
			_tmp78_ = footer;
			_tmp79_ = tick;
			gtk_box_append (_tmp78_, (GtkWidget*) _tmp79_);
		}
		_g_object_unref0 (tick);
	}
	_tmp80_ = footer;
	_tmp81_ = dc_message_row_build_pin_indicator (msg);
	_tmp82_ = _tmp81_;
	gtk_box_append (_tmp80_, (GtkWidget*) _tmp82_);
	_g_object_unref0 (_tmp82_);
	_tmp83_ = bubble;
	_tmp84_ = footer;
	gtk_box_append (_tmp83_, (GtkWidget*) _tmp84_);
	_tmp85_ = dc_message_row_build_reactions_box (msg);
	reactions_box = _tmp85_;
	_tmp86_ = reactions_box;
	if (_tmp86_ != NULL) {
		GtkBox* _tmp87_;
		GtkBox* _tmp88_;
		_tmp87_ = bubble;
		_tmp88_ = reactions_box;
		gtk_box_append (_tmp87_, (GtkWidget*) _tmp88_);
	}
	if (outgoing) {
		GtkBox* spacer = NULL;
		GtkBox* _tmp89_;
		GtkBox* _tmp90_;
		GtkBox* _tmp91_;
		_tmp89_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
		g_object_ref_sink (_tmp89_);
		spacer = _tmp89_;
		_tmp90_ = spacer;
		gtk_widget_set_hexpand ((GtkWidget*) _tmp90_, TRUE);
		_tmp91_ = spacer;
		gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp91_);
		_g_object_unref0 (spacer);
	}
	if (!outgoing) {
		_tmp92_ = show_avatar;
	} else {
		_tmp92_ = FALSE;
	}
	if (_tmp92_) {
		GtkWidget* _tmp93_;
		GtkWidget* _tmp94_;
		_tmp93_ = dc_message_row_build_bubble_avatar (msg);
		_tmp94_ = _tmp93_;
		gtk_box_append ((GtkBox*) self, _tmp94_);
		_g_object_unref0 (_tmp94_);
	}
	_tmp95_ = bubble;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp95_);
	if (outgoing) {
		_tmp96_ = show_avatar;
	} else {
		_tmp96_ = FALSE;
	}
	if (_tmp96_) {
		GtkWidget* _tmp97_;
		GtkWidget* _tmp98_;
		_tmp97_ = dc_message_row_build_bubble_avatar (msg);
		_tmp98_ = _tmp97_;
		gtk_box_append ((GtkBox*) self, _tmp98_);
		_g_object_unref0 (_tmp98_);
	}
	if (!outgoing) {
		GtkBox* spacer = NULL;
		GtkBox* _tmp99_;
		GtkBox* _tmp100_;
		GtkBox* _tmp101_;
		_tmp99_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
		g_object_ref_sink (_tmp99_);
		spacer = _tmp99_;
		_tmp100_ = spacer;
		gtk_widget_set_hexpand ((GtkWidget*) _tmp100_, TRUE);
		_tmp101_ = spacer;
		gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp101_);
		_g_object_unref0 (spacer);
	}
	_g_object_unref0 (reactions_box);
	_g_object_unref0 (time_lbl);
	_g_free0 (time_str);
	_g_object_unref0 (footer);
	_g_object_unref0 (bubble);
	return self;
}

DcMessageRow*
dc_message_row_new (DcMessage* msg,
                    DcMessage* prev,
                    GPtrArray* trailing_images,
                    gboolean is_image_continuation,
                    DcBubbleAvatarDisplay avatar_display,
                    gboolean avatar_scope_enabled,
                    gboolean show_sender_name)
{
	return dc_message_row_construct (DC_TYPE_MESSAGE_ROW, msg, prev, trailing_images, is_image_continuation, avatar_display, avatar_scope_enabled, show_sender_name);
}

static void
dc_message_row_build_irc_row (DcMessageRow* self,
                              DcMessage* msg,
                              DcMessage* prev,
                              GPtrArray* trailing_images,
                              gboolean is_image_continuation)
{
	gchar* time_str = NULL;
	gint64 _tmp0_;
	gint64 _tmp1_;
	gchar* _tmp2_;
	GtkLabel* time_lbl = NULL;
	const gchar* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	const gchar* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	GtkLabel* _tmp13_;
	gchar* sender = NULL;
	gchar* _tmp14_;
	GtkLabel* sender_lbl = NULL;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	GtkLabel* _tmp20_;
	GtkLabel* _tmp21_;
	GtkLabel* _tmp22_;
	const gchar* _tmp23_ = NULL;
	gboolean _tmp24_;
	gboolean _tmp25_;
	GtkLabel* _tmp26_;
	GtkLabel* _tmp27_;
	GtkLabel* _tmp28_;
	GtkLabel* _tmp29_;
	GtkLabel* _tmp30_;
	GtkBox* body = NULL;
	GtkBox* _tmp31_;
	GtkBox* _tmp32_;
	gboolean _tmp33_;
	gboolean _tmp34_;
	gboolean _tmp51_ = FALSE;
	const gchar* _tmp52_;
	const gchar* _tmp53_;
	GtkBox* _tmp61_;
	gboolean _tmp62_ = FALSE;
	const gchar* _tmp63_;
	const gchar* _tmp64_;
	GtkBox* reactions_box = NULL;
	GtkBox* _tmp72_;
	GtkBox* _tmp73_;
	GtkBox* _tmp76_;
	gboolean _tmp77_;
	gboolean _tmp78_;
	gboolean _tmp82_;
	gboolean _tmp83_;
	GtkLabel* pin_icon = NULL;
	GtkLabel* _tmp88_;
	GtkLabel* _tmp89_;
	GtkLabel* _tmp90_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (msg != NULL);
	if (is_image_continuation) {
		gtk_widget_add_css_class ((GtkWidget*) self, "message-irc");
		gtk_widget_add_css_class ((GtkWidget*) self, "message-irc-continuation");
		g_object_set ((GtkWidget*) self, "height-request", 0, NULL);
		gtk_widget_set_visible ((GtkWidget*) self, FALSE);
		return;
	}
	gtk_widget_set_margin_start ((GtkWidget*) self, 8);
	gtk_widget_set_margin_end ((GtkWidget*) self, 8);
	gtk_widget_set_margin_top ((GtkWidget*) self, 0);
	gtk_widget_set_margin_bottom ((GtkWidget*) self, 0);
	gtk_box_set_spacing ((GtkBox*) self, 6);
	gtk_widget_add_css_class ((GtkWidget*) self, "message-irc");
	_tmp0_ = dc_message_get_timestamp (msg);
	_tmp1_ = _tmp0_;
	_tmp2_ = dc_message_row_format_timestamp (_tmp1_);
	time_str = _tmp2_;
	_tmp3_ = time_str;
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	time_lbl = _tmp4_;
	_tmp5_ = time_lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp5_, "message-time");
	_tmp6_ = time_lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp6_, "irc-time");
	_tmp7_ = time_lbl;
	gtk_widget_set_valign ((GtkWidget*) _tmp7_, GTK_ALIGN_START);
	_tmp8_ = time_lbl;
	gtk_label_set_xalign (_tmp8_, (gfloat) 1);
	_tmp9_ = time_lbl;
	_tmp10_ = time_str;
	_tmp11_ = strlen (_tmp10_);
	_tmp12_ = _tmp11_;
	gtk_widget_set_visible ((GtkWidget*) _tmp9_, _tmp12_ > 0);
	_tmp13_ = time_lbl;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp13_);
	_tmp14_ = dc_message_row_effective_sender_name (msg);
	sender = _tmp14_;
	_tmp15_ = sender;
	_tmp16_ = g_strconcat ("<", _tmp15_, NULL);
	_tmp17_ = _tmp16_;
	_tmp18_ = g_strconcat (_tmp17_, ">", NULL);
	_tmp19_ = _tmp18_;
	_tmp20_ = (GtkLabel*) gtk_label_new (_tmp19_);
	g_object_ref_sink (_tmp20_);
	_tmp21_ = _tmp20_;
	_g_free0 (_tmp19_);
	_g_free0 (_tmp17_);
	sender_lbl = _tmp21_;
	_tmp22_ = sender_lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp22_, "message-sender");
	_tmp24_ = dc_message_get_is_outgoing (msg);
	_tmp25_ = _tmp24_;
	if (_tmp25_) {
		_tmp23_ = "message-sender-self";
	} else {
		_tmp23_ = "message-sender-other";
	}
	_tmp26_ = sender_lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp26_, _tmp23_);
	_tmp27_ = sender_lbl;
	gtk_widget_set_valign ((GtkWidget*) _tmp27_, GTK_ALIGN_START);
	_tmp28_ = sender_lbl;
	gtk_label_set_xalign (_tmp28_, (gfloat) 0);
	_tmp29_ = sender_lbl;
	gtk_label_set_ellipsize (_tmp29_, PANGO_ELLIPSIZE_END);
	_tmp30_ = sender_lbl;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp30_);
	_tmp31_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
	g_object_ref_sink (_tmp31_);
	body = _tmp31_;
	_tmp32_ = body;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp32_, TRUE);
	_tmp33_ = dc_message_get_is_forwarded (msg);
	_tmp34_ = _tmp33_;
	if (_tmp34_) {
		GtkLabel* fwd = NULL;
		GtkLabel* _tmp35_;
		GtkLabel* _tmp36_;
		GtkLabel* _tmp37_;
		GtkLabel* _tmp38_;
		gboolean _tmp39_ = FALSE;
		const gchar* _tmp40_;
		const gchar* _tmp41_;
		GtkBox* _tmp49_;
		GtkLabel* _tmp50_;
		_tmp35_ = (GtkLabel*) gtk_label_new ("↪ forwarded");
		g_object_ref_sink (_tmp35_);
		fwd = _tmp35_;
		_tmp36_ = fwd;
		gtk_widget_add_css_class ((GtkWidget*) _tmp36_, "message-forwarded");
		_tmp37_ = fwd;
		gtk_widget_set_halign ((GtkWidget*) _tmp37_, GTK_ALIGN_START);
		_tmp38_ = fwd;
		gtk_label_set_xalign (_tmp38_, (gfloat) 0);
		_tmp40_ = dc_message_get_sender_address (msg);
		_tmp41_ = _tmp40_;
		if (_tmp41_ != NULL) {
			const gchar* _tmp42_;
			const gchar* _tmp43_;
			gint _tmp44_;
			gint _tmp45_;
			_tmp42_ = dc_message_get_sender_address (msg);
			_tmp43_ = _tmp42_;
			_tmp44_ = strlen (_tmp43_);
			_tmp45_ = _tmp44_;
			_tmp39_ = _tmp45_ > 0;
		} else {
			_tmp39_ = FALSE;
		}
		if (_tmp39_) {
			GtkLabel* _tmp46_;
			const gchar* _tmp47_;
			const gchar* _tmp48_;
			_tmp46_ = fwd;
			_tmp47_ = dc_message_get_sender_address (msg);
			_tmp48_ = _tmp47_;
			gtk_widget_set_tooltip_text ((GtkWidget*) _tmp46_, _tmp48_);
		}
		_tmp49_ = body;
		_tmp50_ = fwd;
		gtk_box_append (_tmp49_, (GtkWidget*) _tmp50_);
		_g_object_unref0 (fwd);
	}
	_tmp52_ = dc_message_get_quote_text (msg);
	_tmp53_ = _tmp52_;
	if (_tmp53_ != NULL) {
		const gchar* _tmp54_;
		const gchar* _tmp55_;
		gint _tmp56_;
		gint _tmp57_;
		_tmp54_ = dc_message_get_quote_text (msg);
		_tmp55_ = _tmp54_;
		_tmp56_ = strlen (_tmp55_);
		_tmp57_ = _tmp56_;
		_tmp51_ = _tmp57_ > 0;
	} else {
		_tmp51_ = FALSE;
	}
	if (_tmp51_) {
		GtkBox* _tmp58_;
		GtkButton* _tmp59_;
		GtkButton* _tmp60_;
		_tmp58_ = body;
		_tmp59_ = dc_message_row_build_quote_block (self, msg, 60, 1);
		_tmp60_ = _tmp59_;
		gtk_box_append (_tmp58_, (GtkWidget*) _tmp60_);
		_g_object_unref0 (_tmp60_);
	}
	_tmp61_ = body;
	dc_message_row_append_attachment (self, _tmp61_, msg, TRUE, trailing_images);
	_tmp63_ = dc_message_get_text (msg);
	_tmp64_ = _tmp63_;
	if (_tmp64_ != NULL) {
		const gchar* _tmp65_;
		const gchar* _tmp66_;
		gint _tmp67_;
		gint _tmp68_;
		_tmp65_ = dc_message_get_text (msg);
		_tmp66_ = _tmp65_;
		_tmp67_ = strlen (_tmp66_);
		_tmp68_ = _tmp67_;
		_tmp62_ = _tmp68_ > 0;
	} else {
		_tmp62_ = FALSE;
	}
	if (_tmp62_) {
		GtkBox* _tmp69_;
		GtkWidget* _tmp70_;
		GtkWidget* _tmp71_;
		_tmp69_ = body;
		_tmp70_ = dc_message_row_build_text_widget (self, msg, -1);
		_tmp71_ = _tmp70_;
		gtk_box_append (_tmp69_, _tmp71_);
		_g_object_unref0 (_tmp71_);
	}
	_tmp72_ = dc_message_row_build_reactions_box (msg);
	reactions_box = _tmp72_;
	_tmp73_ = reactions_box;
	if (_tmp73_ != NULL) {
		GtkBox* _tmp74_;
		GtkBox* _tmp75_;
		_tmp74_ = body;
		_tmp75_ = reactions_box;
		gtk_box_append (_tmp74_, (GtkWidget*) _tmp75_);
	}
	_tmp76_ = body;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp76_);
	_tmp77_ = dc_message_get_is_edited (msg);
	_tmp78_ = _tmp77_;
	if (_tmp78_) {
		GtkLabel* edited = NULL;
		GtkLabel* _tmp79_;
		GtkLabel* _tmp80_;
		GtkLabel* _tmp81_;
		_tmp79_ = dc_message_row_build_edited_indicator ("(edited)");
		edited = _tmp79_;
		_tmp80_ = edited;
		gtk_widget_set_valign ((GtkWidget*) _tmp80_, GTK_ALIGN_START);
		_tmp81_ = edited;
		gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp81_);
		_g_object_unref0 (edited);
	}
	_tmp82_ = dc_message_get_is_outgoing (msg);
	_tmp83_ = _tmp82_;
	if (_tmp83_) {
		GtkLabel* tick = NULL;
		GtkLabel* _tmp84_;
		GtkLabel* _tmp85_;
		_tmp84_ = dc_message_row_build_tick_indicator (msg);
		tick = _tmp84_;
		_tmp85_ = tick;
		if (_tmp85_ != NULL) {
			GtkLabel* _tmp86_;
			GtkLabel* _tmp87_;
			_tmp86_ = tick;
			gtk_widget_set_valign ((GtkWidget*) _tmp86_, GTK_ALIGN_START);
			_tmp87_ = tick;
			gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp87_);
		}
		_g_object_unref0 (tick);
	}
	_tmp88_ = dc_message_row_build_pin_indicator (msg);
	pin_icon = _tmp88_;
	_tmp89_ = pin_icon;
	gtk_widget_set_valign ((GtkWidget*) _tmp89_, GTK_ALIGN_START);
	_tmp90_ = pin_icon;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp90_);
	_g_object_unref0 (pin_icon);
	_g_object_unref0 (reactions_box);
	_g_object_unref0 (body);
	_g_object_unref0 (sender_lbl);
	_g_free0 (sender);
	_g_object_unref0 (time_lbl);
	_g_free0 (time_str);
}

static Block18Data*
block18_data_ref (Block18Data* _data18_)
{
	g_atomic_int_inc (&_data18_->_ref_count_);
	return _data18_;
}

static void
block18_data_unref (void * _userdata_)
{
	Block18Data* _data18_;
	_data18_ = (Block18Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data18_->_ref_count_)) {
		DcMessageRow* self;
		self = _data18_->self;
		_g_object_unref0 (_data18_->check);
		_g_object_unref0 (_data18_->msg);
		_g_object_unref0 (self);
		g_slice_free (Block18Data, _data18_);
	}
}

static void
__lambda77_ (Block18Data* _data18_)
{
	DcMessageRow* self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gint _tmp6_;
	gint _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	self = _data18_->self;
	_tmp0_ = dc_message_get_selected (_data18_->msg);
	_tmp1_ = _tmp0_;
	_tmp2_ = gtk_check_button_get_active (_data18_->check);
	_tmp3_ = _tmp2_;
	if (_tmp1_ != _tmp3_) {
		gboolean _tmp4_;
		gboolean _tmp5_;
		_tmp4_ = gtk_check_button_get_active (_data18_->check);
		_tmp5_ = _tmp4_;
		dc_message_set_selected (_data18_->msg, _tmp5_);
	}
	_tmp6_ = dc_message_get_id (_data18_->msg);
	_tmp7_ = _tmp6_;
	_tmp8_ = gtk_check_button_get_active (_data18_->check);
	_tmp9_ = _tmp8_;
	g_signal_emit (self, dc_message_row_signals[DC_MESSAGE_ROW_SELECTION_TOGGLED_SIGNAL], 0, _tmp7_, _tmp9_);
}

static void
___lambda77__gtk_check_button_toggled (GtkCheckButton* _sender,
                                       gpointer self)
{
	__lambda77_ (self);
}

static void
dc_message_row_append_selection_checkbox (DcMessageRow* self,
                                          DcMessage* msg)
{
	Block18Data* _data18_;
	DcMessage* _tmp0_;
	GtkCheckButton* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (msg != NULL);
	_data18_ = g_slice_new0 (Block18Data);
	_data18_->_ref_count_ = 1;
	_data18_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (msg);
	_g_object_unref0 (_data18_->msg);
	_data18_->msg = _tmp0_;
	_tmp1_ = (GtkCheckButton*) gtk_check_button_new ();
	g_object_ref_sink (_tmp1_);
	_data18_->check = _tmp1_;
	gtk_widget_add_css_class ((GtkWidget*) _data18_->check, "message-select-check");
	gtk_widget_set_valign ((GtkWidget*) _data18_->check, GTK_ALIGN_CENTER);
	gtk_widget_set_margin_end ((GtkWidget*) _data18_->check, 6);
	g_object_bind_property_with_closures ((GObject*) _data18_->msg, "selection-visible", (GObject*) _data18_->check, "visible", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_object_bind_property_with_closures ((GObject*) _data18_->msg, "selected", (GObject*) _data18_->check, "active", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_signal_connect_data (_data18_->check, "toggled", (GCallback) ___lambda77__gtk_check_button_toggled, block18_data_ref (_data18_), (GClosureNotify) block18_data_unref, 0);
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _data18_->check);
	block18_data_unref (_data18_);
	_data18_ = NULL;
}

static void
dc_message_row_append_attachment (DcMessageRow* self,
                                  GtkBox* box,
                                  DcMessage* msg,
                                  gboolean irc,
                                  GPtrArray* trailing_images)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GtkBox* fi = NULL;
	GtkBox* _tmp9_;
	GtkBox* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (box != NULL);
	g_return_if_fail (msg != NULL);
	_tmp0_ = dc_message_get_has_file (msg);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	_tmp3_ = dc_message_get_has_local_file (msg);
	_tmp4_ = _tmp3_;
	if (_tmp4_) {
		_tmp2_ = dc_message_is_image_file (msg);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		if (irc) {
			dc_message_row_append_irc_images (box, msg, trailing_images);
		} else {
			dc_message_row_append_bubble_image (box, msg);
		}
		return;
	}
	if (dc_message_is_video_file (msg)) {
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		_tmp5_ = dc_message_row_build_video_preview (msg);
		_tmp6_ = _tmp5_;
		gtk_box_append (box, _tmp6_);
		_g_object_unref0 (_tmp6_);
		return;
	}
	if (dc_message_is_audio_file (msg)) {
		GtkWidget* _tmp7_;
		GtkWidget* _tmp8_;
		_tmp7_ = dc_message_row_build_audio_player (msg);
		_tmp8_ = _tmp7_;
		gtk_box_append (box, _tmp8_);
		_g_object_unref0 (_tmp8_);
		return;
	}
	_tmp9_ = dc_message_row_build_file_indicator (msg);
	fi = _tmp9_;
	if (irc) {
		GtkBox* _tmp10_;
		_tmp10_ = fi;
		gtk_widget_set_halign ((GtkWidget*) _tmp10_, GTK_ALIGN_START);
	}
	_tmp11_ = fi;
	gtk_box_append (box, (GtkWidget*) _tmp11_);
	_g_object_unref0 (fi);
}

static gboolean
dc_message_row_should_show_bubble_avatar (DcMessage* msg,
                                          DcBubbleAvatarDisplay display,
                                          gboolean scope_enabled)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (msg != NULL, FALSE);
	if (!scope_enabled) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp1_;
		gboolean _tmp2_;
		_tmp1_ = dc_message_get_is_info (msg);
		_tmp2_ = _tmp1_;
		_tmp0_ = _tmp2_;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	switch (display) {
		case DC_BUBBLE_AVATAR_DISPLAY_NONE:
		{
			result = FALSE;
			return result;
		}
		case DC_BUBBLE_AVATAR_DISPLAY_OTHER:
		{
			gboolean _tmp3_;
			gboolean _tmp4_;
			_tmp3_ = dc_message_get_is_outgoing (msg);
			_tmp4_ = _tmp3_;
			result = !_tmp4_;
			return result;
		}
		case DC_BUBBLE_AVATAR_DISPLAY_BOTH:
		{
			result = TRUE;
			return result;
		}
		default:
		{
			result = FALSE;
			return result;
		}
	}
}

static GtkWidget*
dc_message_row_build_bubble_avatar (DcMessage* msg)
{
	const gchar* _tmp0_ = NULL;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gchar* text = NULL;
	gchar* _tmp16_;
	const gchar* _tmp17_ = NULL;
	gboolean _tmp18_;
	gboolean _tmp19_;
	GtkWidget* avatar = NULL;
	const gchar* _tmp23_;
	GtkWidget* _tmp24_;
	GtkWidget* _tmp25_;
	GtkWidget* _tmp26_;
	const gchar* _tmp27_;
	gboolean _tmp28_;
	gboolean _tmp29_;
	GtkWidget* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp1_ = dc_message_get_is_outgoing (msg);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		const gchar* _tmp3_ = NULL;
		gboolean _tmp4_ = FALSE;
		const gchar* _tmp5_;
		_tmp5_ = dc_message_row_self_display_name;
		if (_tmp5_ != NULL) {
			const gchar* _tmp6_;
			gint _tmp7_;
			gint _tmp8_;
			_tmp6_ = dc_message_row_self_display_name;
			_tmp7_ = strlen (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp4_ = _tmp8_ > 0;
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			const gchar* _tmp9_;
			_tmp9_ = dc_message_row_self_display_name;
			_tmp3_ = _tmp9_;
		} else {
			_tmp3_ = "me";
		}
		_tmp0_ = _tmp3_;
	} else {
		const gchar* _tmp10_ = NULL;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		_tmp11_ = dc_message_get_sender_name (msg);
		_tmp12_ = _tmp11_;
		_tmp10_ = _tmp12_;
		if (_tmp10_ == NULL) {
			const gchar* _tmp13_ = NULL;
			const gchar* _tmp14_;
			const gchar* _tmp15_;
			_tmp14_ = dc_message_get_sender_address (msg);
			_tmp15_ = _tmp14_;
			_tmp13_ = _tmp15_;
			if (_tmp13_ == NULL) {
				_tmp13_ = "?";
			}
			_tmp10_ = _tmp13_;
		}
		_tmp0_ = _tmp10_;
	}
	_tmp16_ = g_strdup (_tmp0_);
	text = _tmp16_;
	_tmp18_ = dc_message_get_is_outgoing (msg);
	_tmp19_ = _tmp18_;
	if (_tmp19_) {
		const gchar* _tmp20_;
		_tmp20_ = dc_message_row_self_avatar_path;
		_tmp17_ = _tmp20_;
	} else {
		const gchar* _tmp21_;
		const gchar* _tmp22_;
		_tmp21_ = dc_message_get_sender_avatar_path (msg);
		_tmp22_ = _tmp21_;
		_tmp17_ = _tmp22_;
	}
	_tmp23_ = text;
	_tmp24_ = dc_presence_avatar (20, _tmp23_, _tmp17_, FALSE, "message-avatar", NULL);
	avatar = _tmp24_;
	_tmp25_ = avatar;
	gtk_widget_set_valign (_tmp25_, GTK_ALIGN_END);
	_tmp26_ = avatar;
	_tmp27_ = text;
	gtk_widget_set_tooltip_text (_tmp26_, _tmp27_);
	_tmp28_ = dc_message_get_is_outgoing (msg);
	_tmp29_ = _tmp28_;
	if (_tmp29_) {
		GtkWidget* _tmp30_;
		_tmp30_ = avatar;
		gtk_widget_set_margin_start (_tmp30_, 4);
	} else {
		GtkWidget* _tmp31_;
		_tmp31_ = avatar;
		gtk_widget_set_margin_end (_tmp31_, 4);
	}
	result = avatar;
	_g_free0 (text);
	return result;
}

static void
dc_message_row_append_bubble_image (GtkBox* bubble,
                                    DcMessage* msg)
{
	GtkWidget* image = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	g_return_if_fail (bubble != NULL);
	g_return_if_fail (msg != NULL);
	_tmp0_ = dc_message_get_file_path (msg);
	_tmp1_ = _tmp0_;
	_tmp2_ = dc_message_row_load_picture (_tmp1_, 400, 400, 260, 0);
	image = _tmp2_;
	_tmp3_ = image;
	if (_tmp3_ == NULL) {
		GtkBox* _tmp4_;
		GtkBox* _tmp5_;
		_tmp4_ = dc_message_row_build_file_indicator (msg);
		_tmp5_ = _tmp4_;
		gtk_box_append (bubble, (GtkWidget*) _tmp5_);
		_g_object_unref0 (_tmp5_);
	} else {
		GtkWidget* _tmp6_;
		_tmp6_ = image;
		gtk_box_append (bubble, _tmp6_);
	}
	_g_object_unref0 (image);
}

static gint
vala_g_ptr_array_get_length (GPtrArray* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = (gint) self->len;
	return result;
}

static void
dc_message_row_append_irc_images (GtkBox* body,
                                  DcMessage* msg,
                                  GPtrArray* trailing_images)
{
	gint _tmp0_ = 0;
	gboolean _tmp1_ = FALSE;
	GtkBox* strip = NULL;
	GtkBox* _tmp4_;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	GtkBox* _tmp13_;
	g_return_if_fail (body != NULL);
	g_return_if_fail (msg != NULL);
	if (trailing_images != NULL) {
		gint _tmp2_;
		gint _tmp3_;
		_tmp2_ = vala_g_ptr_array_get_length (trailing_images);
		_tmp3_ = _tmp2_;
		_tmp1_ = _tmp3_ > 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = 4;
	} else {
		_tmp0_ = 0;
	}
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, _tmp0_);
	g_object_ref_sink (_tmp4_);
	strip = _tmp4_;
	_tmp5_ = strip;
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_START);
	_tmp6_ = strip;
	dc_message_row_append_irc_image (_tmp6_, msg);
	if (trailing_images != NULL) {
		{
			guint i = 0U;
			i = (guint) 0;
			{
				gboolean _tmp7_ = FALSE;
				_tmp7_ = TRUE;
				while (TRUE) {
					gint _tmp9_;
					gint _tmp10_;
					GtkBox* _tmp11_;
					gconstpointer _tmp12_;
					if (!_tmp7_) {
						guint _tmp8_;
						_tmp8_ = i;
						i = _tmp8_ + 1;
					}
					_tmp7_ = FALSE;
					_tmp9_ = vala_g_ptr_array_get_length (trailing_images);
					_tmp10_ = _tmp9_;
					if (!(i < ((guint) _tmp10_))) {
						break;
					}
					_tmp11_ = strip;
					_tmp12_ = g_ptr_array_index (trailing_images, i);
					dc_message_row_append_irc_image (_tmp11_, (DcMessage*) _tmp12_);
				}
			}
		}
	}
	_tmp13_ = strip;
	gtk_box_append (body, (GtkWidget*) _tmp13_);
	_g_object_unref0 (strip);
}

static void
dc_message_row_append_irc_image (GtkBox* strip,
                                 DcMessage* m)
{
	GtkWidget* picture = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	g_return_if_fail (strip != NULL);
	g_return_if_fail (m != NULL);
	_tmp0_ = dc_message_get_file_path (m);
	_tmp1_ = _tmp0_;
	_tmp2_ = dc_message_row_load_picture (_tmp1_, 260, 200, 0, 180);
	picture = _tmp2_;
	_tmp3_ = picture;
	if (_tmp3_ != NULL) {
		GtkWidget* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		_tmp4_ = picture;
		gtk_widget_add_css_class (_tmp4_, "message-image-irc");
		_tmp5_ = picture;
		gtk_widget_set_halign (_tmp5_, GTK_ALIGN_START);
		_tmp6_ = picture;
		gtk_widget_set_valign (_tmp6_, GTK_ALIGN_START);
		_tmp7_ = picture;
		gtk_box_append (strip, _tmp7_);
	} else {
		GtkLabel* fi = NULL;
		gchar* _tmp8_;
		gchar* _tmp9_;
		GtkLabel* _tmp10_;
		GtkLabel* _tmp11_;
		GtkLabel* _tmp12_;
		GtkLabel* _tmp13_;
		_tmp8_ = dc_message_display_file_name (m, "image");
		_tmp9_ = _tmp8_;
		_tmp10_ = (GtkLabel*) gtk_label_new (_tmp9_);
		g_object_ref_sink (_tmp10_);
		_tmp11_ = _tmp10_;
		_g_free0 (_tmp9_);
		fi = _tmp11_;
		_tmp12_ = fi;
		gtk_widget_add_css_class ((GtkWidget*) _tmp12_, "dim-label");
		_tmp13_ = fi;
		gtk_box_append (strip, (GtkWidget*) _tmp13_);
		_g_object_unref0 (fi);
	}
	_g_object_unref0 (picture);
}

/**
         * Load a file into a Gtk.Picture sized to fit within (max_w, max_h)
         * preserving aspect, then optionally upscaled to (min_w, min_h).
         * Returns null on read failure (and logs to stderr).
         */
static GtkWidget*
dc_message_row_load_picture (const gchar* path,
                             gint max_w,
                             gint max_h,
                             gint min_w,
                             gint min_h)
{
	GError* _inner_error0_ = NULL;
	GtkWidget* result;
	g_return_val_if_fail (path != NULL, NULL);
	{
		gint dw = 0;
		gint dh = 0;
		gboolean _tmp0_ = FALSE;
		gboolean _tmp1_ = FALSE;
		gint _tmp2_ = 0;
		gint _tmp3_ = 0;
		GdkPixbufFormat* _tmp4_;
		GdkPixbuf* pixbuf = NULL;
		GdkPixbuf* _tmp5_;
		GdkTexture* texture = NULL;
		GdkPixbuf* _tmp6_;
		GdkTexture* _tmp7_;
		GtkPicture* picture = NULL;
		GdkTexture* _tmp8_;
		GtkPicture* _tmp9_;
		GtkPicture* _tmp10_;
		GtkPicture* _tmp11_;
		GtkPicture* _tmp12_;
		GtkPicture* _tmp13_;
		DcScaledPreviewFrame* frame = NULL;
		DcScaledPreviewFrame* _tmp14_;
		DcScaledPreviewFrame* _tmp15_;
		GtkPicture* _tmp16_;
		DcScaledPreviewFrame* _tmp17_;
		DcScaledPreviewFrame* _tmp18_;
		_tmp4_ = gdk_pixbuf_get_file_info (path, &_tmp2_, &_tmp3_);
		dw = _tmp2_;
		dh = _tmp3_;
		if (_tmp4_ == NULL) {
			_tmp1_ = TRUE;
		} else {
			_tmp1_ = dw <= 0;
		}
		if (_tmp1_) {
			_tmp0_ = TRUE;
		} else {
			_tmp0_ = dh <= 0;
		}
		if (_tmp0_) {
			result = NULL;
			return result;
		}
		dc_message_row_fit_size (&dw, &dh, max_w, max_h, min_w, min_h);
		_tmp5_ = gdk_pixbuf_new_from_file_at_scale (path, dc_message_row_media_size (dw), dc_message_row_media_size (dh), TRUE, &_inner_error0_);
		pixbuf = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp6_ = pixbuf;
		_tmp7_ = dc_texture_from_pixbuf (_tmp6_);
		texture = _tmp7_;
		_tmp8_ = texture;
		_tmp9_ = (GtkPicture*) gtk_picture_new_for_paintable ((GdkPaintable*) _tmp8_);
		g_object_ref_sink (_tmp9_);
		picture = _tmp9_;
		_tmp10_ = picture;
		gtk_picture_set_content_fit (_tmp10_, GTK_CONTENT_FIT_CONTAIN);
		_tmp11_ = picture;
		gtk_picture_set_can_shrink (_tmp11_, TRUE);
		_tmp12_ = picture;
		gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_FILL);
		_tmp13_ = picture;
		gtk_widget_set_valign ((GtkWidget*) _tmp13_, GTK_ALIGN_FILL);
		_tmp14_ = dc_scaled_preview_frame_new (dw, dh, "message-image");
		g_object_ref_sink (_tmp14_);
		frame = _tmp14_;
		_tmp15_ = frame;
		_tmp16_ = picture;
		dc_scaled_preview_frame_set_child (_tmp15_, (GtkWidget*) _tmp16_);
		_tmp17_ = frame;
		gtk_widget_set_halign ((GtkWidget*) _tmp17_, GTK_ALIGN_START);
		_tmp18_ = frame;
		gtk_widget_set_valign ((GtkWidget*) _tmp18_, GTK_ALIGN_START);
		result = (GtkWidget*) frame;
		_g_object_unref0 (picture);
		_g_object_unref0 (texture);
		_g_object_unref0 (pixbuf);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		FILE* _tmp19_;
		GError* _tmp20_;
		const gchar* _tmp21_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp19_ = stderr;
		_tmp20_ = e;
		_tmp21_ = _tmp20_->message;
		fprintf (_tmp19_, "  -> Image load failed: %s\n", _tmp21_);
		result = NULL;
		_g_error_free0 (e);
		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 NULL;
}

static void
dc_message_row_fit_size (gint* dw,
                         gint* dh,
                         gint max_w,
                         gint max_h,
                         gint min_w,
                         gint min_h)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp2_ = FALSE;
	if (min_w > 0) {
		_tmp0_ = (*dw) < min_w;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		*dh = (gint) ((((gdouble) (*dh)) * min_w) / (*dw));
		*dw = min_w;
	} else {
		gboolean _tmp1_ = FALSE;
		if (max_w > 0) {
			_tmp1_ = (*dw) > max_w;
		} else {
			_tmp1_ = FALSE;
		}
		if (_tmp1_) {
			*dh = (gint) ((((gdouble) (*dh)) * max_w) / (*dw));
			*dw = max_w;
		}
	}
	if (min_h > 0) {
		_tmp2_ = (*dh) < min_h;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		*dw = (gint) ((((gdouble) (*dw)) * min_h) / (*dh));
		*dh = min_h;
	}
}

gboolean
dc_message_row_same_irc_sender (DcMessage* a,
                                DcMessage* b)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	const gchar* _tmp11_ = NULL;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* an = NULL;
	gchar* _tmp14_;
	const gchar* _tmp15_ = NULL;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* bn = NULL;
	gchar* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	gboolean result;
	g_return_val_if_fail (a != NULL, FALSE);
	g_return_val_if_fail (b != NULL, FALSE);
	_tmp1_ = dc_message_get_is_info (a);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp3_ = dc_message_get_is_info (b);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp5_ = dc_message_get_is_outgoing (a);
	_tmp6_ = _tmp5_;
	_tmp7_ = dc_message_get_is_outgoing (b);
	_tmp8_ = _tmp7_;
	if (_tmp6_ != _tmp8_) {
		result = FALSE;
		return result;
	}
	_tmp9_ = dc_message_get_is_outgoing (a);
	_tmp10_ = _tmp9_;
	if (_tmp10_) {
		result = TRUE;
		return result;
	}
	_tmp12_ = dc_message_get_sender_name (a);
	_tmp13_ = _tmp12_;
	_tmp11_ = _tmp13_;
	if (_tmp11_ == NULL) {
		_tmp11_ = "";
	}
	_tmp14_ = g_strdup (_tmp11_);
	an = _tmp14_;
	_tmp16_ = dc_message_get_sender_name (b);
	_tmp17_ = _tmp16_;
	_tmp15_ = _tmp17_;
	if (_tmp15_ == NULL) {
		_tmp15_ = "";
	}
	_tmp18_ = g_strdup (_tmp15_);
	bn = _tmp18_;
	_tmp19_ = an;
	_tmp20_ = bn;
	result = g_strcmp0 (_tmp19_, _tmp20_) == 0;
	_g_free0 (bn);
	_g_free0 (an);
	return result;
}

static gchar*
dc_message_row_effective_sender_name (DcMessage* msg)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	gchar* author = NULL;
	gchar* _tmp10_;
	const gchar* _tmp11_ = NULL;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp0_ = dc_message_get_is_outgoing (msg);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		gboolean _tmp2_ = FALSE;
		const gchar* _tmp3_;
		gchar* _tmp9_;
		_tmp3_ = dc_message_row_self_display_name;
		if (_tmp3_ != NULL) {
			const gchar* _tmp4_;
			gint _tmp5_;
			gint _tmp6_;
			_tmp4_ = dc_message_row_self_display_name;
			_tmp5_ = strlen (_tmp4_);
			_tmp6_ = _tmp5_;
			_tmp2_ = _tmp6_ > 0;
		} else {
			_tmp2_ = FALSE;
		}
		if (_tmp2_) {
			const gchar* _tmp7_;
			gchar* _tmp8_;
			_tmp7_ = dc_message_row_self_display_name;
			_tmp8_ = g_strdup (_tmp7_);
			result = _tmp8_;
			return result;
		}
		_tmp9_ = g_strdup ("me");
		result = _tmp9_;
		return result;
	}
	_tmp10_ = dc_message_row_effective_author_name (msg);
	author = _tmp10_;
	_tmp12_ = author;
	_tmp11_ = _tmp12_;
	if (_tmp11_ == NULL) {
		_tmp11_ = "?";
	}
	_tmp13_ = g_strdup (_tmp11_);
	result = _tmp13_;
	_g_free0 (author);
	return result;
}

/**
         * Display name for an incoming message's author. Prefers the overridden
         * sender name (mailing lists, bots, senders not in the group), shown
         * with a leading "~" per Delta Chat convention; otherwise the contact's
         * display name. Returns null when neither is known.
         */
static gchar*
dc_message_row_effective_author_name (DcMessage* msg)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gboolean _tmp10_ = FALSE;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp1_ = dc_message_get_override_sender_name (msg);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		_tmp3_ = dc_message_get_override_sender_name (msg);
		_tmp4_ = _tmp3_;
		_tmp5_ = strlen (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_ > 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp7_ = dc_message_get_override_sender_name (msg);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_strconcat ("~", _tmp8_, NULL);
		result = _tmp9_;
		return result;
	}
	_tmp11_ = dc_message_get_sender_name (msg);
	_tmp12_ = _tmp11_;
	if (_tmp12_ != NULL) {
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		_tmp13_ = dc_message_get_sender_name (msg);
		_tmp14_ = _tmp13_;
		_tmp15_ = strlen (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp10_ = _tmp16_ > 0;
	} else {
		_tmp10_ = FALSE;
	}
	if (_tmp10_) {
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		gchar* _tmp19_;
		_tmp17_ = dc_message_get_sender_name (msg);
		_tmp18_ = _tmp17_;
		_tmp19_ = g_strdup (_tmp18_);
		result = _tmp19_;
		return result;
	}
	result = NULL;
	return result;
}

/**
         * "Forwarded by <author>" for incoming messages where the forwarder is
         * known, otherwise a plain "Forwarded" marker. Delta Chat does not
         * preserve the original author of forwarded content, so the recoverable
         * identity is the forwarder (sender), exposed as the tooltip address.
         */
static GtkLabel*
dc_message_row_build_forwarded_indicator (DcMessage* msg)
{
	gchar* _tmp0_ = NULL;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gchar* author = NULL;
	gchar* _tmp4_;
	gchar* _tmp5_ = NULL;
	const gchar* _tmp6_;
	GtkLabel* lbl = NULL;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	GtkLabel* _tmp14_;
	gboolean _tmp15_ = FALSE;
	gboolean _tmp16_ = FALSE;
	gboolean _tmp17_;
	gboolean _tmp18_;
	GtkLabel* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp1_ = dc_message_get_is_outgoing (msg);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		_g_free0 (_tmp0_);
		_tmp0_ = NULL;
	} else {
		gchar* _tmp3_;
		_tmp3_ = dc_message_row_effective_author_name (msg);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp3_;
	}
	_tmp4_ = _tmp0_;
	_tmp0_ = NULL;
	author = _tmp4_;
	_tmp6_ = author;
	if (_tmp6_ != NULL) {
		const gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp7_ = author;
		_tmp8_ = g_strconcat ("↪ Forwarded by ", _tmp7_, NULL);
		_g_free0 (_tmp5_);
		_tmp5_ = _tmp8_;
	} else {
		gchar* _tmp9_;
		_tmp9_ = g_strdup ("↪ Forwarded");
		_g_free0 (_tmp5_);
		_tmp5_ = _tmp9_;
	}
	_tmp10_ = (GtkLabel*) gtk_label_new (_tmp5_);
	g_object_ref_sink (_tmp10_);
	lbl = _tmp10_;
	_tmp11_ = lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp11_, "message-forwarded");
	_tmp12_ = lbl;
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_START);
	_tmp13_ = lbl;
	gtk_label_set_xalign (_tmp13_, (gfloat) 0);
	_tmp14_ = lbl;
	gtk_label_set_ellipsize (_tmp14_, PANGO_ELLIPSIZE_END);
	_tmp17_ = dc_message_get_is_outgoing (msg);
	_tmp18_ = _tmp17_;
	if (!_tmp18_) {
		const gchar* _tmp19_;
		const gchar* _tmp20_;
		_tmp19_ = dc_message_get_sender_address (msg);
		_tmp20_ = _tmp19_;
		_tmp16_ = _tmp20_ != NULL;
	} else {
		_tmp16_ = FALSE;
	}
	if (_tmp16_) {
		const gchar* _tmp21_;
		const gchar* _tmp22_;
		gint _tmp23_;
		gint _tmp24_;
		_tmp21_ = dc_message_get_sender_address (msg);
		_tmp22_ = _tmp21_;
		_tmp23_ = strlen (_tmp22_);
		_tmp24_ = _tmp23_;
		_tmp15_ = _tmp24_ > 0;
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		GtkLabel* _tmp25_;
		const gchar* _tmp26_;
		const gchar* _tmp27_;
		_tmp25_ = lbl;
		_tmp26_ = dc_message_get_sender_address (msg);
		_tmp27_ = _tmp26_;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp25_, _tmp27_);
	}
	result = lbl;
	_g_free0 (_tmp5_);
	_g_free0 (author);
	_g_free0 (_tmp0_);
	return result;
}

static GtkLabel*
dc_message_row_build_edited_indicator (const gchar* text)
{
	GtkLabel* lbl = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* result;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (text);
	g_object_ref_sink (_tmp0_);
	lbl = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) lbl, "message-edited");
	gtk_widget_set_tooltip_text ((GtkWidget*) lbl, "This message was edited");
	result = lbl;
	return result;
}

static void
dc_message_row_build_info_row (DcMessageRow* self,
                               DcMessage* msg)
{
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkLabel* label = NULL;
	GtkLabel* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (msg != NULL);
	_tmp1_ = dc_message_get_text (msg);
	_tmp2_ = _tmp1_;
	_tmp0_ = _tmp2_;
	if (_tmp0_ == NULL) {
		_tmp0_ = "";
	}
	_tmp3_ = (GtkLabel*) gtk_label_new (_tmp0_);
	g_object_ref_sink (_tmp3_);
	label = _tmp3_;
	gtk_widget_add_css_class ((GtkWidget*) label, "dim-label");
	gtk_widget_add_css_class ((GtkWidget*) label, "caption");
	gtk_widget_set_hexpand ((GtkWidget*) label, TRUE);
	gtk_widget_set_halign ((GtkWidget*) label, GTK_ALIGN_CENTER);
	gtk_label_set_justify (label, GTK_JUSTIFY_CENTER);
	gtk_widget_set_margin_top ((GtkWidget*) label, 4);
	gtk_widget_set_margin_bottom ((GtkWidget*) label, 4);
	gtk_label_set_wrap (label, TRUE);
	gtk_box_append ((GtkBox*) self, (GtkWidget*) label);
	_g_object_unref0 (label);
}

static GtkWidget*
dc_message_row_build_video_preview (DcMessage* msg)
{
	GtkOverlay* overlay = NULL;
	GtkOverlay* _tmp0_;
	GtkOverlay* _tmp1_;
	GtkOverlay* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkBox* play_box = NULL;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	GtkImage* play = NULL;
	GtkImage* _tmp10_;
	GtkImage* _tmp11_;
	GtkBox* _tmp12_;
	GtkImage* _tmp13_;
	GtkOverlay* _tmp14_;
	GtkBox* _tmp15_;
	gboolean _tmp16_ = FALSE;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	DcScaledPreviewFrame* frame = NULL;
	DcScaledPreviewFrame* _tmp37_;
	GtkOverlay* _tmp38_;
	GtkWidget* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp0_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_ref_sink (_tmp0_);
	overlay = _tmp0_;
	_tmp1_ = overlay;
	gtk_widget_set_halign ((GtkWidget*) _tmp1_, GTK_ALIGN_START);
	_tmp2_ = overlay;
	_tmp3_ = dc_message_row_build_video_paintable (msg);
	_tmp4_ = _tmp3_;
	gtk_overlay_set_child (_tmp2_, _tmp4_);
	_g_object_unref0 (_tmp4_);
	_tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp5_);
	play_box = _tmp5_;
	_tmp6_ = play_box;
	gtk_widget_add_css_class ((GtkWidget*) _tmp6_, "message-video-play");
	_tmp7_ = play_box;
	gtk_widget_set_halign ((GtkWidget*) _tmp7_, GTK_ALIGN_CENTER);
	_tmp8_ = play_box;
	gtk_widget_set_valign ((GtkWidget*) _tmp8_, GTK_ALIGN_CENTER);
	_tmp9_ = play_box;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp9_, "Play video");
	_tmp10_ = (GtkImage*) gtk_image_new_from_icon_name ("media-playback-start-symbolic");
	g_object_ref_sink (_tmp10_);
	play = _tmp10_;
	_tmp11_ = play;
	gtk_image_set_pixel_size (_tmp11_, 20);
	_tmp12_ = play_box;
	_tmp13_ = play;
	gtk_box_append (_tmp12_, (GtkWidget*) _tmp13_);
	_tmp14_ = overlay;
	_tmp15_ = play_box;
	gtk_overlay_add_overlay (_tmp14_, (GtkWidget*) _tmp15_);
	_tmp17_ = dc_message_get_file_name (msg);
	_tmp18_ = _tmp17_;
	if (_tmp18_ != NULL) {
		const gchar* _tmp19_;
		const gchar* _tmp20_;
		gint _tmp21_;
		gint _tmp22_;
		_tmp19_ = dc_message_get_file_name (msg);
		_tmp20_ = _tmp19_;
		_tmp21_ = strlen (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp16_ = _tmp22_ > 0;
	} else {
		_tmp16_ = FALSE;
	}
	if (_tmp16_) {
		GtkLabel* name = NULL;
		const gchar* _tmp23_;
		const gchar* _tmp24_;
		GtkLabel* _tmp25_;
		GtkLabel* _tmp26_;
		GtkLabel* _tmp27_;
		GtkLabel* _tmp28_;
		GtkLabel* _tmp29_;
		GtkLabel* _tmp30_;
		GtkLabel* _tmp31_;
		GtkLabel* _tmp32_;
		GtkLabel* _tmp33_;
		GtkLabel* _tmp34_;
		GtkOverlay* _tmp35_;
		GtkLabel* _tmp36_;
		_tmp23_ = dc_message_get_file_name (msg);
		_tmp24_ = _tmp23_;
		_tmp25_ = (GtkLabel*) gtk_label_new (_tmp24_);
		g_object_ref_sink (_tmp25_);
		name = _tmp25_;
		_tmp26_ = name;
		gtk_widget_add_css_class ((GtkWidget*) _tmp26_, "message-video-name");
		_tmp27_ = name;
		gtk_label_set_ellipsize (_tmp27_, PANGO_ELLIPSIZE_MIDDLE);
		_tmp28_ = name;
		gtk_label_set_max_width_chars (_tmp28_, 30);
		_tmp29_ = name;
		gtk_widget_set_halign ((GtkWidget*) _tmp29_, GTK_ALIGN_START);
		_tmp30_ = name;
		gtk_widget_set_valign ((GtkWidget*) _tmp30_, GTK_ALIGN_END);
		_tmp31_ = name;
		gtk_label_set_xalign (_tmp31_, (gfloat) 0);
		_tmp32_ = name;
		gtk_widget_set_margin_start ((GtkWidget*) _tmp32_, 8);
		_tmp33_ = name;
		gtk_widget_set_margin_end ((GtkWidget*) _tmp33_, 8);
		_tmp34_ = name;
		gtk_widget_set_margin_bottom ((GtkWidget*) _tmp34_, 6);
		_tmp35_ = overlay;
		_tmp36_ = name;
		gtk_overlay_add_overlay (_tmp35_, (GtkWidget*) _tmp36_);
		_g_object_unref0 (name);
	}
	_tmp37_ = dc_scaled_preview_frame_new (260, 150, "message-video-frame");
	g_object_ref_sink (_tmp37_);
	frame = _tmp37_;
	_tmp38_ = overlay;
	dc_scaled_preview_frame_set_child (frame, (GtkWidget*) _tmp38_);
	result = (GtkWidget*) frame;
	_g_object_unref0 (play);
	_g_object_unref0 (play_box);
	_g_object_unref0 (overlay);
	return result;
}

static GtkWidget*
dc_message_row_build_video_paintable (DcMessage* msg)
{
	GtkPicture* preview = NULL;
	gboolean _tmp0_;
	gboolean _tmp1_;
	GtkPicture* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GtkPicture* _tmp14_;
	GtkPicture* _tmp15_;
	GtkPicture* _tmp16_;
	GtkWidget* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp0_ = dc_message_get_has_local_file (msg);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		GtkMediaFile* media = NULL;
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		GtkMediaFile* _tmp4_;
		GtkMediaFile* _tmp5_;
		GtkMediaFile* _tmp6_;
		GtkPicture* _tmp7_;
		_tmp2_ = dc_message_get_file_path (msg);
		_tmp3_ = _tmp2_;
		_tmp4_ = (GtkMediaFile*) gtk_media_file_new_for_filename (_tmp3_);
		media = _tmp4_;
		_tmp5_ = media;
		gtk_media_stream_pause ((GtkMediaStream*) _tmp5_);
		_tmp6_ = media;
		_tmp7_ = (GtkPicture*) gtk_picture_new_for_paintable ((GdkPaintable*) _tmp6_);
		g_object_ref_sink (_tmp7_);
		_g_object_unref0 (preview);
		preview = _tmp7_;
		_g_object_unref0 (media);
	} else {
		GdkPaintable* _tmp8_;
		GdkPaintable* _tmp9_;
		GtkPicture* _tmp10_;
		_tmp8_ = gdk_paintable_new_empty (260, 150);
		_tmp9_ = _tmp8_;
		_tmp10_ = (GtkPicture*) gtk_picture_new_for_paintable (_tmp9_);
		g_object_ref_sink (_tmp10_);
		_g_object_unref0 (preview);
		preview = _tmp10_;
		_g_object_unref0 (_tmp9_);
	}
	_tmp11_ = preview;
	_tmp12_ = dc_message_display_file_name (msg, "video");
	_tmp13_ = _tmp12_;
	gtk_picture_set_alternative_text (_tmp11_, _tmp13_);
	_g_free0 (_tmp13_);
	_tmp14_ = preview;
	gtk_picture_set_can_shrink (_tmp14_, TRUE);
	_tmp15_ = preview;
	gtk_picture_set_content_fit (_tmp15_, GTK_CONTENT_FIT_COVER);
	_tmp16_ = preview;
	gtk_widget_add_css_class ((GtkWidget*) _tmp16_, "message-video-bg");
	result = (GtkWidget*) preview;
	return result;
}

static GtkWidget*
dc_message_row_build_audio_player (DcMessage* msg)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	DcAudioPlayer* _tmp7_;
	GtkWidget* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp0_ = dc_message_get_has_local_file (msg);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		GtkBox* _tmp2_;
		_tmp2_ = dc_message_row_build_file_indicator (msg);
		result = (GtkWidget*) _tmp2_;
		return result;
	}
	_tmp3_ = dc_message_get_file_path (msg);
	_tmp4_ = _tmp3_;
	_tmp5_ = dc_message_get_file_name (msg);
	_tmp6_ = _tmp5_;
	_tmp7_ = dc_audio_player_new (_tmp4_, _tmp6_);
	g_object_ref_sink (_tmp7_);
	result = (GtkWidget*) _tmp7_;
	return result;
}

static GtkBox*
dc_message_row_build_file_indicator (DcMessage* msg)
{
	GtkBox* file_box = NULL;
	GtkBox* _tmp0_;
	GtkImage* icon = NULL;
	GtkImage* _tmp1_;
	GtkLabel* fname = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkBox* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp0_);
	file_box = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) file_box, "message-attachment");
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("mail-attachment-symbolic");
	g_object_ref_sink (_tmp1_);
	icon = _tmp1_;
	gtk_image_set_pixel_size (icon, 16);
	gtk_box_append (file_box, (GtkWidget*) icon);
	_tmp2_ = dc_message_display_file_name (msg, "file");
	_tmp3_ = _tmp2_;
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	fname = _tmp5_;
	gtk_widget_add_css_class ((GtkWidget*) fname, "dim-label");
	gtk_label_set_ellipsize (fname, PANGO_ELLIPSIZE_MIDDLE);
	gtk_label_set_max_width_chars (fname, 28);
	gtk_box_append (file_box, (GtkWidget*) fname);
	result = file_box;
	_g_object_unref0 (fname);
	_g_object_unref0 (icon);
	return result;
}

static GtkLabel*
dc_message_row_build_tick_indicator (DcMessage* msg)
{
	gchar* glyph = NULL;
	gchar* extra_class = NULL;
	gchar* tooltip = NULL;
	gboolean _tmp0_;
	gboolean _tmp1_;
	GtkLabel* lbl = NULL;
	const gchar* _tmp20_;
	GtkLabel* _tmp21_;
	GtkLabel* _tmp22_;
	GtkLabel* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	GtkLabel* result;
	g_return_val_if_fail (msg != NULL, NULL);
	tooltip = NULL;
	_tmp0_ = dc_message_get_is_failed (msg);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp2_ = g_strdup ("⚠");
		_g_free0 (glyph);
		glyph = _tmp2_;
		_tmp3_ = g_strdup ("message-tick-failed");
		_g_free0 (extra_class);
		extra_class = _tmp3_;
		_tmp4_ = g_strdup ("Sending failed");
		_g_free0 (tooltip);
		tooltip = _tmp4_;
	} else {
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp5_ = dc_message_get_is_read (msg);
		_tmp6_ = _tmp5_;
		if (_tmp6_) {
			gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			_tmp7_ = g_strdup ("✓✓");
			_g_free0 (glyph);
			glyph = _tmp7_;
			_tmp8_ = g_strdup ("message-tick-read");
			_g_free0 (extra_class);
			extra_class = _tmp8_;
			_tmp9_ = g_strdup ("Read");
			_g_free0 (tooltip);
			tooltip = _tmp9_;
		} else {
			gboolean _tmp10_;
			gboolean _tmp11_;
			_tmp10_ = dc_message_get_is_delivered (msg);
			_tmp11_ = _tmp10_;
			if (_tmp11_) {
				gchar* _tmp12_;
				gchar* _tmp13_;
				gchar* _tmp14_;
				_tmp12_ = g_strdup ("✓");
				_g_free0 (glyph);
				glyph = _tmp12_;
				_tmp13_ = g_strdup ("message-tick");
				_g_free0 (extra_class);
				extra_class = _tmp13_;
				_tmp14_ = g_strdup ("Delivered");
				_g_free0 (tooltip);
				tooltip = _tmp14_;
			} else {
				gboolean _tmp15_;
				gboolean _tmp16_;
				_tmp15_ = dc_message_get_is_pending (msg);
				_tmp16_ = _tmp15_;
				if (_tmp16_) {
					gchar* _tmp17_;
					gchar* _tmp18_;
					gchar* _tmp19_;
					_tmp17_ = g_strdup ("⧖");
					_g_free0 (glyph);
					glyph = _tmp17_;
					_tmp18_ = g_strdup ("message-tick");
					_g_free0 (extra_class);
					extra_class = _tmp18_;
					_tmp19_ = g_strdup ("Sending…");
					_g_free0 (tooltip);
					tooltip = _tmp19_;
				} else {
					result = NULL;
					_g_free0 (tooltip);
					_g_free0 (extra_class);
					_g_free0 (glyph);
					return result;
				}
			}
		}
	}
	_tmp20_ = glyph;
	_tmp21_ = (GtkLabel*) gtk_label_new (_tmp20_);
	g_object_ref_sink (_tmp21_);
	lbl = _tmp21_;
	_tmp22_ = lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp22_, "message-time");
	_tmp23_ = lbl;
	_tmp24_ = extra_class;
	gtk_widget_add_css_class ((GtkWidget*) _tmp23_, _tmp24_);
	_tmp25_ = tooltip;
	if (_tmp25_ != NULL) {
		GtkLabel* _tmp26_;
		const gchar* _tmp27_;
		_tmp26_ = lbl;
		_tmp27_ = tooltip;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp26_, _tmp27_);
	}
	result = lbl;
	_g_free0 (tooltip);
	_g_free0 (extra_class);
	_g_free0 (glyph);
	return result;
}

static GtkLabel*
dc_message_row_build_pin_indicator (DcMessage* msg)
{
	GtkLabel* pin = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new ("📌");
	g_object_ref_sink (_tmp0_);
	pin = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) pin, "message-pin");
	gtk_widget_set_tooltip_text ((GtkWidget*) pin, "Pinned");
	g_object_bind_property_with_closures ((GObject*) msg, "is-pinned", (GObject*) pin, "visible", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	result = pin;
	return result;
}

static Block19Data*
block19_data_ref (Block19Data* _data19_)
{
	g_atomic_int_inc (&_data19_->_ref_count_);
	return _data19_;
}

static void
block19_data_unref (void * _userdata_)
{
	Block19Data* _data19_;
	_data19_ = (Block19Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data19_->_ref_count_)) {
		DcMessageRow* self;
		self = _data19_->self;
		_g_object_unref0 (self);
		g_slice_free (Block19Data, _data19_);
	}
}

static void
___lambda69_ (Block19Data* _data19_)
{
	DcMessageRow* self;
	self = _data19_->self;
	g_signal_emit (self, dc_message_row_signals[DC_MESSAGE_ROW_QUOTE_CLICKED_SIGNAL], 0, _data19_->qid);
}

static void
____lambda69__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	___lambda69_ (self);
}

static GtkButton*
dc_message_row_build_quote_block (DcMessageRow* self,
                                  DcMessage* msg,
                                  gint max_width_chars,
                                  gint lines)
{
	GtkButton* btn = NULL;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean stacked = FALSE;
	GtkButton* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp0_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp0_);
	btn = _tmp0_;
	_tmp1_ = btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp1_, "flat");
	_tmp2_ = btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp2_, "quote-block");
	_tmp3_ = dc_message_get_quote_msg_id (msg);
	_tmp4_ = _tmp3_;
	if (_tmp4_ > 0) {
		Block19Data* _data19_;
		gint _tmp5_;
		gint _tmp6_;
		GtkButton* _tmp7_;
		_data19_ = g_slice_new0 (Block19Data);
		_data19_->_ref_count_ = 1;
		_data19_->self = g_object_ref (self);
		_tmp5_ = dc_message_get_quote_msg_id (msg);
		_tmp6_ = _tmp5_;
		_data19_->qid = _tmp6_;
		_tmp7_ = btn;
		g_signal_connect_data (_tmp7_, "clicked", (GCallback) ____lambda69__gtk_button_clicked, block19_data_ref (_data19_), (GClosureNotify) block19_data_unref, 0);
		block19_data_unref (_data19_);
		_data19_ = NULL;
	}
	if (lines > 1) {
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		_tmp10_ = dc_message_get_quote_sender_name (msg);
		_tmp11_ = _tmp10_;
		_tmp9_ = _tmp11_ != NULL;
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		_tmp12_ = dc_message_get_quote_sender_name (msg);
		_tmp13_ = _tmp12_;
		_tmp14_ = strlen (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp8_ = _tmp15_ > 0;
	} else {
		_tmp8_ = FALSE;
	}
	stacked = _tmp8_;
	if (stacked) {
		GtkBox* box = NULL;
		GtkBox* _tmp16_;
		GtkLabel* s = NULL;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		GtkLabel* _tmp19_;
		GtkLabel* _tmp20_;
		GtkLabel* _tmp21_;
		GtkLabel* _tmp22_;
		GtkBox* _tmp23_;
		GtkLabel* _tmp24_;
		GtkLabel* t = NULL;
		const gchar* _tmp25_;
		const gchar* _tmp26_;
		GtkLabel* _tmp27_;
		GtkLabel* _tmp28_;
		GtkLabel* _tmp29_;
		GtkLabel* _tmp30_;
		GtkLabel* _tmp31_;
		GtkLabel* _tmp32_;
		GtkLabel* _tmp33_;
		GtkBox* _tmp34_;
		GtkLabel* _tmp35_;
		GtkButton* _tmp36_;
		GtkBox* _tmp37_;
		_tmp16_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
		g_object_ref_sink (_tmp16_);
		box = _tmp16_;
		_tmp17_ = dc_message_get_quote_sender_name (msg);
		_tmp18_ = _tmp17_;
		_tmp19_ = (GtkLabel*) gtk_label_new (_tmp18_);
		g_object_ref_sink (_tmp19_);
		s = _tmp19_;
		_tmp20_ = s;
		gtk_widget_add_css_class ((GtkWidget*) _tmp20_, "quote-sender");
		_tmp21_ = s;
		gtk_widget_set_halign ((GtkWidget*) _tmp21_, GTK_ALIGN_START);
		_tmp22_ = s;
		gtk_label_set_xalign (_tmp22_, (gfloat) 0);
		_tmp23_ = box;
		_tmp24_ = s;
		gtk_box_append (_tmp23_, (GtkWidget*) _tmp24_);
		_tmp25_ = dc_message_get_quote_text (msg);
		_tmp26_ = _tmp25_;
		_tmp27_ = (GtkLabel*) gtk_label_new (_tmp26_);
		g_object_ref_sink (_tmp27_);
		t = _tmp27_;
		_tmp28_ = t;
		gtk_widget_add_css_class ((GtkWidget*) _tmp28_, "quote-text");
		_tmp29_ = t;
		gtk_widget_set_halign ((GtkWidget*) _tmp29_, GTK_ALIGN_START);
		_tmp30_ = t;
		gtk_label_set_xalign (_tmp30_, (gfloat) 0);
		_tmp31_ = t;
		gtk_label_set_ellipsize (_tmp31_, PANGO_ELLIPSIZE_END);
		_tmp32_ = t;
		gtk_label_set_max_width_chars (_tmp32_, max_width_chars);
		_tmp33_ = t;
		gtk_label_set_lines (_tmp33_, lines);
		_tmp34_ = box;
		_tmp35_ = t;
		gtk_box_append (_tmp34_, (GtkWidget*) _tmp35_);
		_tmp36_ = btn;
		_tmp37_ = box;
		gtk_button_set_child (_tmp36_, (GtkWidget*) _tmp37_);
		_g_object_unref0 (t);
		_g_object_unref0 (s);
		_g_object_unref0 (box);
	} else {
		gchar* _tmp38_ = NULL;
		gboolean _tmp39_ = FALSE;
		const gchar* _tmp40_;
		const gchar* _tmp41_;
		gchar* prefix = NULL;
		gchar* _tmp50_;
		GtkLabel* t = NULL;
		const gchar* _tmp51_;
		const gchar* _tmp52_;
		const gchar* _tmp53_;
		gchar* _tmp54_;
		gchar* _tmp55_;
		GtkLabel* _tmp56_;
		GtkLabel* _tmp57_;
		GtkLabel* _tmp58_;
		GtkLabel* _tmp59_;
		GtkLabel* _tmp60_;
		GtkLabel* _tmp61_;
		GtkLabel* _tmp62_;
		GtkLabel* _tmp63_;
		GtkButton* _tmp64_;
		GtkLabel* _tmp65_;
		_tmp40_ = dc_message_get_quote_sender_name (msg);
		_tmp41_ = _tmp40_;
		if (_tmp41_ != NULL) {
			const gchar* _tmp42_;
			const gchar* _tmp43_;
			gint _tmp44_;
			gint _tmp45_;
			_tmp42_ = dc_message_get_quote_sender_name (msg);
			_tmp43_ = _tmp42_;
			_tmp44_ = strlen (_tmp43_);
			_tmp45_ = _tmp44_;
			_tmp39_ = _tmp45_ > 0;
		} else {
			_tmp39_ = FALSE;
		}
		if (_tmp39_) {
			const gchar* _tmp46_;
			const gchar* _tmp47_;
			gchar* _tmp48_;
			_tmp46_ = dc_message_get_quote_sender_name (msg);
			_tmp47_ = _tmp46_;
			_tmp48_ = g_strconcat (_tmp47_, ": ", NULL);
			_g_free0 (_tmp38_);
			_tmp38_ = _tmp48_;
		} else {
			gchar* _tmp49_;
			_tmp49_ = g_strdup ("");
			_g_free0 (_tmp38_);
			_tmp38_ = _tmp49_;
		}
		_tmp50_ = _tmp38_;
		_tmp38_ = NULL;
		prefix = _tmp50_;
		_tmp51_ = prefix;
		_tmp52_ = dc_message_get_quote_text (msg);
		_tmp53_ = _tmp52_;
		_tmp54_ = g_strconcat (_tmp51_, _tmp53_, NULL);
		_tmp55_ = _tmp54_;
		_tmp56_ = (GtkLabel*) gtk_label_new (_tmp55_);
		g_object_ref_sink (_tmp56_);
		_tmp57_ = _tmp56_;
		_g_free0 (_tmp55_);
		t = _tmp57_;
		_tmp58_ = t;
		gtk_widget_add_css_class ((GtkWidget*) _tmp58_, "quote-text");
		_tmp59_ = t;
		gtk_widget_set_halign ((GtkWidget*) _tmp59_, GTK_ALIGN_START);
		_tmp60_ = t;
		gtk_label_set_xalign (_tmp60_, (gfloat) 0);
		_tmp61_ = t;
		gtk_label_set_ellipsize (_tmp61_, PANGO_ELLIPSIZE_END);
		_tmp62_ = t;
		gtk_label_set_max_width_chars (_tmp62_, max_width_chars);
		_tmp63_ = t;
		gtk_label_set_lines (_tmp63_, lines);
		_tmp64_ = btn;
		_tmp65_ = t;
		gtk_button_set_child (_tmp64_, (GtkWidget*) _tmp65_);
		_g_object_unref0 (t);
		_g_free0 (prefix);
		_g_free0 (_tmp38_);
	}
	result = btn;
	return result;
}

/** Message body widget with markdown + link markup. Shared by both row styles. */
static Block20Data*
block20_data_ref (Block20Data* _data20_)
{
	g_atomic_int_inc (&_data20_->_ref_count_);
	return _data20_;
}

static void
block20_data_unref (void * _userdata_)
{
	Block20Data* _data20_;
	_data20_ = (Block20Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data20_->_ref_count_)) {
		DcMessageRow* self;
		self = _data20_->self;
		_g_object_unref0 (_data20_->msg);
		_g_object_unref0 (self);
		g_slice_free (Block20Data, _data20_);
	}
}

static void
___lambda76_ (Block20Data* _data20_)
{
	DcMessageRow* self;
	gint _tmp0_;
	gint _tmp1_;
	self = _data20_->self;
	_tmp0_ = dc_message_get_id (_data20_->msg);
	_tmp1_ = _tmp0_;
	g_signal_emit (self, dc_message_row_signals[DC_MESSAGE_ROW_FULL_MESSAGE_REQUESTED_SIGNAL], 0, _tmp1_);
}

static void
____lambda76__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	___lambda76_ (self);
}

static GtkWidget*
dc_message_row_build_text_widget (DcMessageRow* self,
                                  DcMessage* msg,
                                  gint max_width_chars)
{
	Block20Data* _data20_;
	DcMessage* _tmp0_;
	GtkWidget* body = NULL;
	gboolean _tmp18_ = FALSE;
	gboolean _tmp19_;
	gboolean _tmp20_;
	GtkBox* box = NULL;
	GtkBox* _tmp23_;
	GtkBox* _tmp24_;
	GtkBox* _tmp25_;
	GtkWidget* _tmp26_;
	gboolean _tmp27_;
	gboolean _tmp28_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (msg != NULL, NULL);
	_data20_ = g_slice_new0 (Block20Data);
	_data20_->_ref_count_ = 1;
	_data20_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (msg);
	_g_object_unref0 (_data20_->msg);
	_data20_->msg = _tmp0_;
	if (dc_markdown_enabled) {
		GtkWidget* table_body = NULL;
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_ = NULL;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp12_;
		_tmp1_ = dc_message_get_text (_data20_->msg);
		_tmp2_ = _tmp1_;
		_tmp3_ = dc_message_row_build_text_with_tables (_tmp2_, max_width_chars);
		table_body = _tmp3_;
		_tmp5_ = table_body;
		_tmp6_ = _g_object_ref0 (_tmp5_);
		_tmp4_ = _tmp6_;
		if (_tmp4_ == NULL) {
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			const gchar* _tmp9_;
			const gchar* _tmp10_;
			GtkLabel* _tmp11_;
			_tmp7_ = dc_message_get_text (_data20_->msg);
			_tmp8_ = _tmp7_;
			_tmp9_ = dc_message_get_text (_data20_->msg);
			_tmp10_ = _tmp9_;
			_tmp11_ = dc_message_row_build_markup_label (_tmp8_, max_width_chars, dc_message_row_is_single_emoji_text (_tmp10_));
			_g_object_unref0 (_tmp4_);
			_tmp4_ = (GtkWidget*) _tmp11_;
		}
		_tmp12_ = _tmp4_;
		_tmp4_ = NULL;
		_g_object_unref0 (body);
		body = _tmp12_;
		_g_object_unref0 (_tmp4_);
		_g_object_unref0 (table_body);
	} else {
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		GtkLabel* _tmp17_;
		_tmp13_ = dc_message_get_text (_data20_->msg);
		_tmp14_ = _tmp13_;
		_tmp15_ = dc_message_get_text (_data20_->msg);
		_tmp16_ = _tmp15_;
		_tmp17_ = dc_message_row_build_markup_label (_tmp14_, max_width_chars, dc_message_row_is_single_emoji_text (_tmp16_));
		_g_object_unref0 (body);
		body = (GtkWidget*) _tmp17_;
	}
	_tmp19_ = dc_message_get_has_full_message_action (_data20_->msg);
	_tmp20_ = _tmp19_;
	if (!_tmp20_) {
		gboolean _tmp21_;
		gboolean _tmp22_;
		_tmp21_ = dc_message_get_is_downloading_full_message (_data20_->msg);
		_tmp22_ = _tmp21_;
		_tmp18_ = !_tmp22_;
	} else {
		_tmp18_ = FALSE;
	}
	if (_tmp18_) {
		result = body;
		block20_data_unref (_data20_);
		_data20_ = NULL;
		return result;
	}
	_tmp23_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
	g_object_ref_sink (_tmp23_);
	box = _tmp23_;
	_tmp24_ = box;
	gtk_widget_set_halign ((GtkWidget*) _tmp24_, GTK_ALIGN_FILL);
	_tmp25_ = box;
	_tmp26_ = body;
	gtk_box_append (_tmp25_, _tmp26_);
	_tmp27_ = dc_message_get_is_downloading_full_message (_data20_->msg);
	_tmp28_ = _tmp27_;
	if (_tmp28_) {
		GtkLabel* status = NULL;
		GtkLabel* _tmp29_;
		GtkLabel* _tmp30_;
		GtkLabel* _tmp31_;
		GtkLabel* _tmp32_;
		GtkBox* _tmp33_;
		GtkLabel* _tmp34_;
		_tmp29_ = (GtkLabel*) gtk_label_new ("Downloading full message...");
		g_object_ref_sink (_tmp29_);
		status = _tmp29_;
		_tmp30_ = status;
		gtk_widget_add_css_class ((GtkWidget*) _tmp30_, "message-full-text-status");
		_tmp31_ = status;
		gtk_widget_set_halign ((GtkWidget*) _tmp31_, GTK_ALIGN_START);
		_tmp32_ = status;
		gtk_label_set_xalign (_tmp32_, (gfloat) 0);
		_tmp33_ = box;
		_tmp34_ = status;
		gtk_box_append (_tmp33_, (GtkWidget*) _tmp34_);
		_g_object_unref0 (status);
	} else {
		const gchar* _tmp35_ = NULL;
		gboolean _tmp36_;
		gboolean _tmp37_;
		GtkButton* btn = NULL;
		GtkButton* _tmp38_;
		GtkButton* _tmp39_;
		GtkButton* _tmp40_;
		GtkButton* _tmp41_;
		GtkButton* _tmp42_;
		GtkBox* _tmp43_;
		GtkButton* _tmp44_;
		_tmp36_ = dc_message_get_can_download_full_message (_data20_->msg);
		_tmp37_ = _tmp36_;
		if (_tmp37_) {
			_tmp35_ = "Download full message";
		} else {
			_tmp35_ = "Show full message";
		}
		_tmp38_ = (GtkButton*) gtk_button_new_with_label (_tmp35_);
		g_object_ref_sink (_tmp38_);
		btn = _tmp38_;
		_tmp39_ = btn;
		gtk_widget_add_css_class ((GtkWidget*) _tmp39_, "flat");
		_tmp40_ = btn;
		gtk_widget_add_css_class ((GtkWidget*) _tmp40_, "message-full-text-button");
		_tmp41_ = btn;
		gtk_widget_set_halign ((GtkWidget*) _tmp41_, GTK_ALIGN_START);
		_tmp42_ = btn;
		g_signal_connect_data (_tmp42_, "clicked", (GCallback) ____lambda76__gtk_button_clicked, block20_data_ref (_data20_), (GClosureNotify) block20_data_unref, 0);
		_tmp43_ = box;
		_tmp44_ = btn;
		gtk_box_append (_tmp43_, (GtkWidget*) _tmp44_);
		_g_object_unref0 (btn);
	}
	result = (GtkWidget*) box;
	_g_object_unref0 (body);
	block20_data_unref (_data20_);
	_data20_ = NULL;
	return result;
}

static inline GRegex*
_thread_safe_regex_init (GRegex** re,
                         const gchar * pattern,
                         GRegexCompileFlags compile_flags)
{
	if (g_once_init_enter ((volatile gsize*) re)) {
		GRegex* val = g_regex_new (pattern, compile_flags, 0, NULL);
		g_once_init_leave ((volatile gsize*) re, (gsize) val);
	}
	return *re;
}

static GtkLabel*
dc_message_row_build_markup_label (const gchar* raw,
                                   gint max_width_chars,
                                   gboolean big_emoji)
{
	GtkLabel* text = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	GtkLabel* _tmp14_;
	GtkLabel* _tmp17_;
	GError* _inner_error0_ = NULL;
	GtkLabel* result;
	g_return_val_if_fail (raw != NULL, NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (raw);
	g_object_ref_sink (_tmp0_);
	text = _tmp0_;
	{
		gchar* markup = NULL;
		gchar* _tmp1_;
		gchar* probe = NULL;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		PangoAttrList* attrs = NULL;
		gchar* parsed = NULL;
		gunichar accel = 0U;
		const gchar* _tmp4_;
		PangoAttrList* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		gunichar _tmp7_ = 0U;
		GtkLabel* _tmp8_;
		const gchar* _tmp9_;
		_tmp1_ = dc_markdown_format (raw);
		markup = _tmp1_;
		_tmp2_ = markup;
		_tmp3_ = g_regex_replace (_thread_safe_regex_init (&_tmp_regex_0, "<\\/?a(\\s[^>]*)?>", 0), _tmp2_, (gssize) -1, 0, "", 0, &_inner_error0_);
		probe = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (markup);
			goto __catch0_g_error;
		}
		_tmp4_ = probe;
		pango_parse_markup (_tmp4_, -1, (gunichar) 0, &_tmp5_, &_tmp6_, &_tmp7_, &_inner_error0_);
		_pango_attr_list_unref0 (attrs);
		attrs = _tmp5_;
		_g_free0 (parsed);
		parsed = _tmp6_;
		accel = _tmp7_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (parsed);
			_pango_attr_list_unref0 (attrs);
			_g_free0 (probe);
			_g_free0 (markup);
			goto __catch0_g_error;
		}
		_tmp8_ = text;
		_tmp9_ = markup;
		gtk_label_set_markup (_tmp8_, _tmp9_);
		_g_free0 (parsed);
		_pango_attr_list_unref0 (attrs);
		_g_free0 (probe);
		_g_free0 (markup);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (text);
		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;
	}
	_tmp10_ = text;
	gtk_label_set_wrap (_tmp10_, TRUE);
	_tmp11_ = text;
	gtk_label_set_wrap_mode (_tmp11_, PANGO_WRAP_WORD_CHAR);
	_tmp12_ = text;
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_START);
	_tmp13_ = text;
	gtk_label_set_xalign (_tmp13_, (gfloat) 0);
	_tmp14_ = text;
	gtk_label_set_selectable (_tmp14_, TRUE);
	if (big_emoji) {
		GtkLabel* _tmp15_;
		_tmp15_ = text;
		gtk_widget_add_css_class ((GtkWidget*) _tmp15_, "message-big-emoji");
	}
	if (max_width_chars > 0) {
		GtkLabel* _tmp16_;
		_tmp16_ = text;
		gtk_label_set_max_width_chars (_tmp16_, max_width_chars);
	}
	_tmp17_ = text;
	dc_message_row_connect_label_links (_tmp17_);
	result = text;
	return result;
}

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_)) {
		_g_object_unref0 (_data21_->text);
		g_slice_free (Block21Data, _data21_);
	}
}

static gboolean
__lambda70_ (Block21Data* _data21_,
             const gchar* uri)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (uri != NULL, FALSE);
	if (dc_is_delta_invite_uri (uri)) {
		GtkRoot* _tmp1_;
		_tmp1_ = gtk_widget_get_root ((GtkWidget*) _data21_->text);
		_tmp0_ = DC_IS_WINDOW (_tmp1_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GtkRoot* _tmp2_;
		_tmp2_ = gtk_widget_get_root ((GtkWidget*) _data21_->text);
		dc_window_handle_invite_uri (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, DC_TYPE_WINDOW, DcWindow), uri);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda70__gtk_label_activate_link (GtkLabel* _sender,
                                      const gchar* uri,
                                      gpointer self)
{
	gboolean result;
	result = __lambda70_ (self, uri);
	return result;
}

static void
dc_message_row_connect_label_links (GtkLabel* text)
{
	Block21Data* _data21_;
	GtkLabel* _tmp0_;
	g_return_if_fail (text != NULL);
	_data21_ = g_slice_new0 (Block21Data);
	_data21_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (text);
	_g_object_unref0 (_data21_->text);
	_data21_->text = _tmp0_;
	g_signal_connect_data (_data21_->text, "activate-link", (GCallback) ___lambda70__gtk_label_activate_link, block21_data_ref (_data21_), (GClosureNotify) block21_data_unref, 0);
	block21_data_unref (_data21_);
	_data21_ = NULL;
}

static GtkWidget*
dc_message_row_build_text_with_tables (const gchar* raw,
                                       gint max_width_chars)
{
	gchar** lines = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint lines_length1;
	gint _lines_size_;
	GtkBox* body = NULL;
	GtkBox* _tmp2_;
	GtkBox* _tmp3_;
	GtkBox* _tmp4_;
	gboolean found_table = FALSE;
	gboolean in_code_block = FALSE;
	gint text_start = 0;
	GtkBox* _tmp22_;
	gchar** _tmp23_;
	gint _tmp23__length1;
	gchar** _tmp24_;
	gint _tmp24__length1;
	GtkWidget* result;
	g_return_val_if_fail (raw != NULL, NULL);
	_tmp1_ = _tmp0_ = g_strsplit (raw, "\n", 0);
	lines = _tmp1_;
	lines_length1 = _vala_array_length (_tmp0_);
	_lines_size_ = lines_length1;
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
	g_object_ref_sink (_tmp2_);
	body = _tmp2_;
	_tmp3_ = body;
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_FILL);
	_tmp4_ = body;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp4_, TRUE);
	found_table = FALSE;
	in_code_block = FALSE;
	text_start = 0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				gchar** _tmp6_;
				gint _tmp6__length1;
				gchar** _tmp7_;
				gint _tmp7__length1;
				const gchar* _tmp8_;
				gint end = 0;
				DcMessageRowMarkdownTableBlock* table = NULL;
				gchar** _tmp11_;
				gint _tmp11__length1;
				gint _tmp12_ = 0;
				DcMessageRowMarkdownTableBlock* _tmp13_;
				DcMessageRowMarkdownTableBlock* _tmp14_;
				GtkBox* _tmp16_;
				gchar** _tmp17_;
				gint _tmp17__length1;
				GtkBox* _tmp18_;
				DcMessageRowMarkdownTableBlock* _tmp19_;
				GtkWidget* _tmp20_;
				GtkWidget* _tmp21_;
				if (!_tmp5_) {
				}
				_tmp5_ = FALSE;
				_tmp6_ = lines;
				_tmp6__length1 = lines_length1;
				if (!(i < _tmp6__length1)) {
					break;
				}
				_tmp7_ = lines;
				_tmp7__length1 = lines_length1;
				_tmp8_ = _tmp7_[i];
				if (dc_message_row_is_code_fence_line (_tmp8_)) {
					gint _tmp9_;
					in_code_block = !in_code_block;
					_tmp9_ = i;
					i = _tmp9_ + 1;
					continue;
				}
				if (in_code_block) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
					continue;
				}
				_tmp11_ = lines;
				_tmp11__length1 = lines_length1;
				_tmp13_ = dc_message_row_parse_table_at (_tmp11_, (gint) _tmp11__length1, i, &_tmp12_);
				end = _tmp12_;
				table = _tmp13_;
				_tmp14_ = table;
				if (_tmp14_ == NULL) {
					gint _tmp15_;
					_tmp15_ = i;
					i = _tmp15_ + 1;
					_dc_message_row_markdown_table_block_unref0 (table);
					continue;
				}
				_tmp16_ = body;
				_tmp17_ = lines;
				_tmp17__length1 = lines_length1;
				dc_message_row_append_text_block (_tmp16_, _tmp17_, (gint) _tmp17__length1, text_start, i, max_width_chars);
				_tmp18_ = body;
				_tmp19_ = table;
				_tmp20_ = dc_message_row_build_table_grid (_tmp19_, max_width_chars);
				_tmp21_ = _tmp20_;
				gtk_box_append (_tmp18_, _tmp21_);
				_g_object_unref0 (_tmp21_);
				found_table = TRUE;
				i = end;
				text_start = i;
				_dc_message_row_markdown_table_block_unref0 (table);
			}
		}
	}
	if (!found_table) {
		result = NULL;
		_g_object_unref0 (body);
		lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	_tmp22_ = body;
	_tmp23_ = lines;
	_tmp23__length1 = lines_length1;
	_tmp24_ = lines;
	_tmp24__length1 = lines_length1;
	dc_message_row_append_text_block (_tmp22_, _tmp23_, (gint) _tmp23__length1, text_start, _tmp24__length1, max_width_chars);
	result = (GtkWidget*) body;
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

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 gboolean
dc_message_row_is_code_fence_line (const gchar* line)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (line != NULL, FALSE);
	_tmp0_ = string_strip (line);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_str_has_prefix (_tmp1_, "```");
	_g_free0 (_tmp1_);
	result = _tmp2_;
	return result;
}

static void
dc_message_row_append_text_block (GtkBox* body,
                                  gchar** lines,
                                  gint lines_length1,
                                  gint start,
                                  gint end,
                                  gint max_width_chars)
{
	gchar* text = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	const gchar* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	g_return_if_fail (body != NULL);
	_tmp0_ = dc_message_row_join_lines (lines, (gint) lines_length1, start, end);
	_tmp1_ = _tmp0_;
	_tmp2_ = string_strip (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	text = _tmp3_;
	_tmp4_ = text;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_ == 0) {
		_g_free0 (text);
		return;
	}
	_tmp7_ = text;
	_tmp8_ = dc_message_row_build_markup_label (_tmp7_, max_width_chars, FALSE);
	_tmp9_ = _tmp8_;
	gtk_box_append (body, (GtkWidget*) _tmp9_);
	_g_object_unref0 (_tmp9_);
	_g_free0 (text);
}

static gchar*
dc_message_row_join_lines (gchar** lines,
                           gint lines_length1,
                           gint start,
                           gint end)
{
	GString* sb = NULL;
	GString* _tmp0_;
	GString* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* result;
	_tmp0_ = g_string_new ("");
	sb = _tmp0_;
	{
		gint i = 0;
		i = start;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GString* _tmp4_;
				const gchar* _tmp5_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < end)) {
					break;
				}
				if (i > start) {
					GString* _tmp3_;
					_tmp3_ = sb;
					g_string_append_c (_tmp3_, '\n');
				}
				_tmp4_ = sb;
				_tmp5_ = lines[i];
				g_string_append (_tmp4_, _tmp5_);
			}
		}
	}
	_tmp6_ = sb;
	_tmp7_ = _tmp6_->str;
	_tmp8_ = g_strdup (_tmp7_);
	result = _tmp8_;
	_g_string_free0 (sb);
	return result;
}

static DcMessageRowMarkdownTableBlock*
dc_message_row_parse_table_at (gchar** lines,
                               gint lines_length1,
                               gint start,
                               gint* end)
{
	gint _vala_end = 0;
	gchar** header = NULL;
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gchar** _tmp2_;
	gint header_length1;
	gint _header_size_;
	gchar** separator = NULL;
	const gchar* _tmp3_;
	gint _tmp4_ = 0;
	gchar** _tmp5_;
	gint separator_length1;
	gint _separator_size_;
	gboolean _tmp6_ = FALSE;
	gchar** _tmp7_;
	gint _tmp7__length1;
	gboolean _tmp9_ = FALSE;
	gchar** _tmp10_;
	gint _tmp10__length1;
	gchar** _tmp13_;
	gint _tmp13__length1;
	DcMessageRowMarkdownTableBlock* table = NULL;
	gchar** _tmp14_;
	gint _tmp14__length1;
	DcMessageRowMarkdownTableBlock* _tmp15_;
	DcMessageRowMarkdownTableBlock* _tmp23_;
	GPtrArray* _tmp24_;
	gchar** _tmp25_;
	gint _tmp25__length1;
	DcMessageRowMarkdownTableRow* _tmp26_;
	DcMessageRowMarkdownTableBlock* result;
	_vala_end = start;
	if ((start + 1) >= lines_length1) {
		result = NULL;
		if (end) {
			*end = _vala_end;
		}
		return result;
	}
	_tmp0_ = lines[start];
	_tmp2_ = dc_message_row_parse_table_row (_tmp0_, &_tmp1_);
	header = _tmp2_;
	header_length1 = _tmp1_;
	_header_size_ = header_length1;
	_tmp3_ = lines[start + 1];
	_tmp5_ = dc_message_row_parse_table_row (_tmp3_, &_tmp4_);
	separator = _tmp5_;
	separator_length1 = _tmp4_;
	_separator_size_ = separator_length1;
	_tmp7_ = header;
	_tmp7__length1 = header_length1;
	if (_tmp7_ == NULL) {
		_tmp6_ = TRUE;
	} else {
		gchar** _tmp8_;
		gint _tmp8__length1;
		_tmp8_ = separator;
		_tmp8__length1 = separator_length1;
		_tmp6_ = _tmp8_ == NULL;
	}
	if (_tmp6_) {
		result = NULL;
		separator = (_vala_array_free (separator, separator_length1, (GDestroyNotify) g_free), NULL);
		header = (_vala_array_free (header, header_length1, (GDestroyNotify) g_free), NULL);
		if (end) {
			*end = _vala_end;
		}
		return result;
	}
	_tmp10_ = header;
	_tmp10__length1 = header_length1;
	if (_tmp10__length1 < 2) {
		_tmp9_ = TRUE;
	} else {
		gchar** _tmp11_;
		gint _tmp11__length1;
		gchar** _tmp12_;
		gint _tmp12__length1;
		_tmp11_ = header;
		_tmp11__length1 = header_length1;
		_tmp12_ = separator;
		_tmp12__length1 = separator_length1;
		_tmp9_ = _tmp11__length1 != _tmp12__length1;
	}
	if (_tmp9_) {
		result = NULL;
		separator = (_vala_array_free (separator, separator_length1, (GDestroyNotify) g_free), NULL);
		header = (_vala_array_free (header, header_length1, (GDestroyNotify) g_free), NULL);
		if (end) {
			*end = _vala_end;
		}
		return result;
	}
	_tmp13_ = separator;
	_tmp13__length1 = separator_length1;
	if (!dc_message_row_is_table_separator (_tmp13_, (gint) _tmp13__length1)) {
		result = NULL;
		separator = (_vala_array_free (separator, separator_length1, (GDestroyNotify) g_free), NULL);
		header = (_vala_array_free (header, header_length1, (GDestroyNotify) g_free), NULL);
		if (end) {
			*end = _vala_end;
		}
		return result;
	}
	_tmp14_ = header;
	_tmp14__length1 = header_length1;
	_tmp15_ = dc_message_row_markdown_table_block_new (_tmp14__length1);
	table = _tmp15_;
	{
		gint c = 0;
		c = 0;
		{
			gboolean _tmp16_ = FALSE;
			_tmp16_ = TRUE;
			while (TRUE) {
				gchar** _tmp18_;
				gint _tmp18__length1;
				DcMessageRowMarkdownTableBlock* _tmp19_;
				gint* _tmp20_;
				gint _tmp20__length1;
				gchar** _tmp21_;
				gint _tmp21__length1;
				const gchar* _tmp22_;
				if (!_tmp16_) {
					gint _tmp17_;
					_tmp17_ = c;
					c = _tmp17_ + 1;
				}
				_tmp16_ = FALSE;
				_tmp18_ = header;
				_tmp18__length1 = header_length1;
				if (!(c < _tmp18__length1)) {
					break;
				}
				_tmp19_ = table;
				_tmp20_ = _tmp19_->aligns;
				_tmp20__length1 = _tmp19_->aligns_length1;
				_tmp21_ = separator;
				_tmp21__length1 = separator_length1;
				_tmp22_ = _tmp21_[c];
				_tmp20_[c] = dc_message_row_table_separator_align (_tmp22_);
			}
		}
	}
	_tmp23_ = table;
	_tmp24_ = _tmp23_->rows;
	_tmp25_ = header;
	_tmp25__length1 = header_length1;
	_tmp26_ = dc_message_row_markdown_table_row_new (_tmp25_, _tmp25__length1, TRUE);
	g_ptr_array_add (_tmp24_, _tmp26_);
	_vala_end = start + 2;
	while (TRUE) {
		gchar* line = NULL;
		const gchar* _tmp27_;
		gchar* _tmp28_;
		const gchar* _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		gint _tmp32_;
		gint _tmp33_;
		gboolean _tmp34_;
		gchar** cells = NULL;
		const gchar* _tmp35_;
		gint _tmp36_ = 0;
		gchar** _tmp37_;
		gint cells_length1;
		gint _cells_size_;
		gboolean _tmp38_ = FALSE;
		gchar** _tmp39_;
		gint _tmp39__length1;
		DcMessageRowMarkdownTableBlock* _tmp42_;
		GPtrArray* _tmp43_;
		gchar** _tmp44_;
		gint _tmp44__length1;
		DcMessageRowMarkdownTableRow* _tmp45_;
		gint _tmp46_;
		if (!(_vala_end < lines_length1)) {
			break;
		}
		_tmp27_ = lines[_vala_end];
		_tmp28_ = g_strdup (_tmp27_);
		line = _tmp28_;
		_tmp29_ = line;
		_tmp30_ = string_strip (_tmp29_);
		_tmp31_ = _tmp30_;
		_tmp32_ = strlen (_tmp31_);
		_tmp33_ = _tmp32_;
		_tmp34_ = _tmp33_ == 0;
		_g_free0 (_tmp31_);
		if (_tmp34_) {
			_g_free0 (line);
			break;
		}
		_tmp35_ = line;
		_tmp37_ = dc_message_row_parse_table_row (_tmp35_, &_tmp36_);
		cells = _tmp37_;
		cells_length1 = _tmp36_;
		_cells_size_ = cells_length1;
		_tmp39_ = cells;
		_tmp39__length1 = cells_length1;
		if (_tmp39_ == NULL) {
			_tmp38_ = TRUE;
		} else {
			gchar** _tmp40_;
			gint _tmp40__length1;
			gchar** _tmp41_;
			gint _tmp41__length1;
			_tmp40_ = cells;
			_tmp40__length1 = cells_length1;
			_tmp41_ = header;
			_tmp41__length1 = header_length1;
			_tmp38_ = _tmp40__length1 != _tmp41__length1;
		}
		if (_tmp38_) {
			cells = (_vala_array_free (cells, cells_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (line);
			break;
		}
		_tmp42_ = table;
		_tmp43_ = _tmp42_->rows;
		_tmp44_ = cells;
		_tmp44__length1 = cells_length1;
		_tmp45_ = dc_message_row_markdown_table_row_new (_tmp44_, _tmp44__length1, FALSE);
		g_ptr_array_add (_tmp43_, _tmp45_);
		_tmp46_ = _vala_end;
		_vala_end = _tmp46_ + 1;
		cells = (_vala_array_free (cells, cells_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (line);
	}
	result = table;
	separator = (_vala_array_free (separator, separator_length1, (GDestroyNotify) g_free), NULL);
	header = (_vala_array_free (header, header_length1, (GDestroyNotify) g_free), NULL);
	if (end) {
		*end = _vala_end;
	}
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	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_message_row_parse_table_row (const gchar* line,
                                gint* result_length1)
{
	gchar* trimmed = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* inner = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp9_;
	gchar** raw = NULL;
	const gchar* _tmp18_;
	gchar** _tmp19_;
	gchar** _tmp20_;
	gint raw_length1;
	gint _raw_size_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	gchar** cells = NULL;
	gchar** _tmp23_;
	gint _tmp23__length1;
	gchar** _tmp24_;
	gint cells_length1;
	gint _cells_size_;
	gchar** _tmp32_;
	gint _tmp32__length1;
	gchar** result;
	g_return_val_if_fail (line != NULL, NULL);
	_tmp0_ = string_strip (line);
	trimmed = _tmp0_;
	_tmp1_ = trimmed;
	if (!string_contains (_tmp1_, "|")) {
		gchar** _tmp2_;
		gint _tmp2__length1;
		_tmp2_ = NULL;
		_tmp2__length1 = 0;
		if (result_length1) {
			*result_length1 = _tmp2__length1;
		}
		result = _tmp2_;
		_g_free0 (trimmed);
		return result;
	}
	_tmp3_ = trimmed;
	_tmp4_ = g_strdup (_tmp3_);
	inner = _tmp4_;
	_tmp5_ = inner;
	if (g_str_has_prefix (_tmp5_, "|")) {
		const gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp6_ = inner;
		_tmp7_ = string_substring (_tmp6_, (glong) 1, (glong) -1);
		_g_free0 (inner);
		inner = _tmp7_;
	}
	_tmp9_ = inner;
	if (g_str_has_suffix (_tmp9_, "|")) {
		const gchar* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		_tmp10_ = inner;
		_tmp11_ = strlen (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp8_ = _tmp12_ > 0;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		gchar* _tmp17_;
		_tmp13_ = inner;
		_tmp14_ = inner;
		_tmp15_ = strlen (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = string_substring (_tmp13_, (glong) 0, (glong) (_tmp16_ - 1));
		_g_free0 (inner);
		inner = _tmp17_;
	}
	_tmp18_ = inner;
	_tmp20_ = _tmp19_ = g_strsplit (_tmp18_, "|", 0);
	raw = _tmp20_;
	raw_length1 = _vala_array_length (_tmp19_);
	_raw_size_ = raw_length1;
	_tmp21_ = raw;
	_tmp21__length1 = raw_length1;
	if (_tmp21__length1 < 2) {
		gchar** _tmp22_;
		gint _tmp22__length1;
		_tmp22_ = NULL;
		_tmp22__length1 = 0;
		if (result_length1) {
			*result_length1 = _tmp22__length1;
		}
		result = _tmp22_;
		raw = (_vala_array_free (raw, raw_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (inner);
		_g_free0 (trimmed);
		return result;
	}
	_tmp23_ = raw;
	_tmp23__length1 = raw_length1;
	_tmp24_ = g_new0 (gchar*, _tmp23__length1 + 1);
	cells = _tmp24_;
	cells_length1 = _tmp23__length1;
	_cells_size_ = cells_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp25_ = FALSE;
			_tmp25_ = TRUE;
			while (TRUE) {
				gchar** _tmp27_;
				gint _tmp27__length1;
				gchar** _tmp28_;
				gint _tmp28__length1;
				gchar** _tmp29_;
				gint _tmp29__length1;
				const gchar* _tmp30_;
				gchar* _tmp31_;
				if (!_tmp25_) {
					gint _tmp26_;
					_tmp26_ = i;
					i = _tmp26_ + 1;
				}
				_tmp25_ = FALSE;
				_tmp27_ = raw;
				_tmp27__length1 = raw_length1;
				if (!(i < _tmp27__length1)) {
					break;
				}
				_tmp28_ = cells;
				_tmp28__length1 = cells_length1;
				_tmp29_ = raw;
				_tmp29__length1 = raw_length1;
				_tmp30_ = _tmp29_[i];
				_tmp31_ = string_strip (_tmp30_);
				_g_free0 (_tmp28_[i]);
				_tmp28_[i] = _tmp31_;
			}
		}
	}
	_tmp32_ = cells;
	_tmp32__length1 = cells_length1;
	if (result_length1) {
		*result_length1 = _tmp32__length1;
	}
	result = _tmp32_;
	raw = (_vala_array_free (raw, raw_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (inner);
	_g_free0 (trimmed);
	return result;
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static gboolean
dc_message_row_is_table_separator (gchar** cells,
                                   gint cells_length1)
{
	gboolean result;
	{
		gchar** cell_collection = NULL;
		gint cell_collection_length1 = 0;
		gint _cell_collection_size_ = 0;
		gint cell_it = 0;
		cell_collection = cells;
		cell_collection_length1 = cells_length1;
		for (cell_it = 0; cell_it < cell_collection_length1; cell_it = cell_it + 1) {
			gchar* _tmp0_;
			gchar* cell = NULL;
			_tmp0_ = g_strdup (cell_collection[cell_it]);
			cell = _tmp0_;
			{
				gchar* s = NULL;
				const gchar* _tmp1_;
				gchar* _tmp2_;
				gint _tmp3_ = 0;
				const gchar* _tmp4_;
				gint start = 0;
				gint _tmp5_ = 0;
				const gchar* _tmp6_;
				gint end = 0;
				_tmp1_ = cell;
				_tmp2_ = string_strip (_tmp1_);
				s = _tmp2_;
				_tmp4_ = s;
				if (g_str_has_prefix (_tmp4_, ":")) {
					_tmp3_ = 1;
				} else {
					_tmp3_ = 0;
				}
				start = _tmp3_;
				_tmp6_ = s;
				if (g_str_has_suffix (_tmp6_, ":")) {
					const gchar* _tmp7_;
					gint _tmp8_;
					gint _tmp9_;
					_tmp7_ = s;
					_tmp8_ = strlen (_tmp7_);
					_tmp9_ = _tmp8_;
					_tmp5_ = _tmp9_ - 1;
				} else {
					const gchar* _tmp10_;
					gint _tmp11_;
					gint _tmp12_;
					_tmp10_ = s;
					_tmp11_ = strlen (_tmp10_);
					_tmp12_ = _tmp11_;
					_tmp5_ = _tmp12_;
				}
				end = _tmp5_;
				if ((end - start) < 3) {
					result = FALSE;
					_g_free0 (s);
					_g_free0 (cell);
					return result;
				}
				{
					gint i = 0;
					i = start;
					{
						gboolean _tmp13_ = FALSE;
						_tmp13_ = TRUE;
						while (TRUE) {
							const gchar* _tmp15_;
							if (!_tmp13_) {
								gint _tmp14_;
								_tmp14_ = i;
								i = _tmp14_ + 1;
							}
							_tmp13_ = FALSE;
							if (!(i < end)) {
								break;
							}
							_tmp15_ = s;
							if (string_get (_tmp15_, (glong) i) != '-') {
								result = FALSE;
								_g_free0 (s);
								_g_free0 (cell);
								return result;
							}
						}
					}
				}
				_g_free0 (s);
				_g_free0 (cell);
			}
		}
	}
	result = TRUE;
	return result;
}

static gint
dc_message_row_table_separator_align (const gchar* cell)
{
	gchar* s = NULL;
	gchar* _tmp0_;
	gboolean left = FALSE;
	const gchar* _tmp1_;
	gboolean right = FALSE;
	const gchar* _tmp2_;
	gboolean _tmp3_ = FALSE;
	gint result;
	g_return_val_if_fail (cell != NULL, -1);
	_tmp0_ = string_strip (cell);
	s = _tmp0_;
	_tmp1_ = s;
	left = g_str_has_prefix (_tmp1_, ":");
	_tmp2_ = s;
	right = g_str_has_suffix (_tmp2_, ":");
	if (left) {
		_tmp3_ = right;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		result = DC_MESSAGE_ROW_ALIGN_CENTER;
		_g_free0 (s);
		return result;
	}
	if (right) {
		result = DC_MESSAGE_ROW_ALIGN_RIGHT;
		_g_free0 (s);
		return result;
	}
	result = DC_MESSAGE_ROW_ALIGN_LEFT;
	_g_free0 (s);
	return result;
}

static gpointer
_dc_message_row_markdown_table_row_ref0 (gpointer self)
{
	return self ? dc_message_row_markdown_table_row_ref (self) : NULL;
}

static GtkWidget*
dc_message_row_build_table_grid (DcMessageRowMarkdownTableBlock* table,
                                 gint max_width_chars)
{
	GtkGrid* grid = NULL;
	GtkGrid* _tmp0_;
	GtkGrid* _tmp1_;
	GtkGrid* _tmp2_;
	GtkGrid* _tmp3_;
	GtkGrid* _tmp4_;
	GtkGrid* _tmp5_;
	gint columns = 0;
	gint* _tmp6_;
	gint _tmp6__length1;
	gint cell_width = 0;
	GtkWidget* result;
	g_return_val_if_fail (table != NULL, NULL);
	_tmp0_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp0_);
	grid = _tmp0_;
	_tmp1_ = grid;
	gtk_widget_add_css_class ((GtkWidget*) _tmp1_, "markdown-table");
	_tmp2_ = grid;
	gtk_widget_set_halign ((GtkWidget*) _tmp2_, GTK_ALIGN_FILL);
	_tmp3_ = grid;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp3_, TRUE);
	_tmp4_ = grid;
	gtk_grid_set_column_spacing (_tmp4_, 0);
	_tmp5_ = grid;
	gtk_grid_set_row_spacing (_tmp5_, 0);
	_tmp6_ = table->aligns;
	_tmp6__length1 = table->aligns_length1;
	columns = _tmp6__length1;
	cell_width = dc_message_row_table_cell_width_chars (columns, max_width_chars);
	{
		gint r = 0;
		r = 0;
		{
			gboolean _tmp7_ = FALSE;
			_tmp7_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp9_;
				gint _tmp10_;
				gint _tmp11_;
				DcMessageRowMarkdownTableRow* row = NULL;
				GPtrArray* _tmp12_;
				gconstpointer _tmp13_;
				DcMessageRowMarkdownTableRow* _tmp14_;
				if (!_tmp7_) {
					gint _tmp8_;
					_tmp8_ = r;
					r = _tmp8_ + 1;
				}
				_tmp7_ = FALSE;
				_tmp9_ = table->rows;
				_tmp10_ = vala_g_ptr_array_get_length (_tmp9_);
				_tmp11_ = _tmp10_;
				if (!(r < _tmp11_)) {
					break;
				}
				_tmp12_ = table->rows;
				_tmp13_ = g_ptr_array_index (_tmp12_, (guint) r);
				_tmp14_ = _dc_message_row_markdown_table_row_ref0 ((DcMessageRowMarkdownTableRow*) _tmp13_);
				row = _tmp14_;
				{
					gint c = 0;
					c = 0;
					{
						gboolean _tmp15_ = FALSE;
						_tmp15_ = TRUE;
						while (TRUE) {
							GtkWidget* cell = NULL;
							DcMessageRowMarkdownTableRow* _tmp17_;
							gchar** _tmp18_;
							gint _tmp18__length1;
							const gchar* _tmp19_;
							gint* _tmp20_;
							gint _tmp20__length1;
							gint _tmp21_;
							DcMessageRowMarkdownTableRow* _tmp22_;
							GtkWidget* _tmp23_;
							GtkGrid* _tmp24_;
							GtkWidget* _tmp25_;
							if (!_tmp15_) {
								gint _tmp16_;
								_tmp16_ = c;
								c = _tmp16_ + 1;
							}
							_tmp15_ = FALSE;
							if (!(c < columns)) {
								break;
							}
							_tmp17_ = row;
							_tmp18_ = _tmp17_->cells;
							_tmp18__length1 = _tmp17_->cells_length1;
							_tmp19_ = _tmp18_[c];
							_tmp20_ = table->aligns;
							_tmp20__length1 = table->aligns_length1;
							_tmp21_ = _tmp20_[c];
							_tmp22_ = row;
							_tmp23_ = dc_message_row_build_table_cell (_tmp19_, cell_width, _tmp21_, _tmp22_->header);
							cell = _tmp23_;
							_tmp24_ = grid;
							_tmp25_ = cell;
							gtk_grid_attach (_tmp24_, _tmp25_, c, r, 1, 1);
							_g_object_unref0 (cell);
						}
					}
				}
				_dc_message_row_markdown_table_row_unref0 (row);
			}
		}
	}
	result = (GtkWidget*) grid;
	return result;
}

static gint
dc_message_row_table_cell_width_chars (gint columns,
                                       gint max_width_chars)
{
	gint _tmp0_ = 0;
	gint total = 0;
	gint width = 0;
	gint result;
	if (max_width_chars > 0) {
		_tmp0_ = max_width_chars;
	} else {
		_tmp0_ = 84;
	}
	total = _tmp0_;
	width = (total - ((columns - 1) * 3)) / columns;
	result = MAX (6, MIN (28, width));
	return result;
}

static GtkWidget*
dc_message_row_build_table_cell (const gchar* raw,
                                 gint width_chars,
                                 gint align,
                                 gboolean header)
{
	GtkLabel* label = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	gfloat _tmp7_ = 0.0F;
	GtkLabel* _tmp9_;
	GtkJustification _tmp10_ = 0;
	GtkLabel* _tmp12_;
	GtkWidget* result;
	g_return_val_if_fail (raw != NULL, NULL);
	_tmp0_ = dc_message_row_build_markup_label (raw, width_chars, FALSE);
	label = _tmp0_;
	_tmp1_ = label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp1_, "markdown-table-cell");
	if (header) {
		GtkLabel* _tmp2_;
		_tmp2_ = label;
		gtk_widget_add_css_class ((GtkWidget*) _tmp2_, "markdown-table-header");
	}
	_tmp3_ = label;
	gtk_widget_set_valign ((GtkWidget*) _tmp3_, GTK_ALIGN_START);
	_tmp4_ = label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp4_, TRUE);
	_tmp5_ = label;
	gtk_label_set_width_chars (_tmp5_, MIN (width_chars, 18));
	_tmp6_ = label;
	gtk_label_set_max_width_chars (_tmp6_, width_chars);
	if (align == DC_MESSAGE_ROW_ALIGN_RIGHT) {
		_tmp7_ = 1.0f;
	} else {
		gfloat _tmp8_ = 0.0F;
		if (align == DC_MESSAGE_ROW_ALIGN_CENTER) {
			_tmp8_ = 0.5f;
		} else {
			_tmp8_ = 0.0f;
		}
		_tmp7_ = _tmp8_;
	}
	_tmp9_ = label;
	gtk_label_set_xalign (_tmp9_, _tmp7_);
	if (align == DC_MESSAGE_ROW_ALIGN_RIGHT) {
		_tmp10_ = GTK_JUSTIFY_RIGHT;
	} else {
		GtkJustification _tmp11_ = 0;
		if (align == DC_MESSAGE_ROW_ALIGN_CENTER) {
			_tmp11_ = GTK_JUSTIFY_CENTER;
		} else {
			_tmp11_ = GTK_JUSTIFY_LEFT;
		}
		_tmp10_ = _tmp11_;
	}
	_tmp12_ = label;
	gtk_label_set_justify (_tmp12_, _tmp10_);
	result = (GtkWidget*) label;
	return result;
}

static gboolean
dc_message_row_is_single_emoji_text (const gchar* raw)
{
	gchar* text = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint index = 0;
	const gchar* _tmp4_;
	gboolean _tmp5_;
	const gchar* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	gboolean result;
	if (raw == NULL) {
		result = FALSE;
		return result;
	}
	_tmp0_ = string_strip (raw);
	text = _tmp0_;
	_tmp1_ = text;
	_tmp2_ = strlen (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == 0) {
		result = FALSE;
		_g_free0 (text);
		return result;
	}
	index = 0;
	_tmp4_ = text;
	_tmp5_ = dc_message_row_consume_emoji_sequence (_tmp4_, &index);
	if (!_tmp5_) {
		result = FALSE;
		_g_free0 (text);
		return result;
	}
	_tmp6_ = text;
	_tmp7_ = strlen (_tmp6_);
	_tmp8_ = _tmp7_;
	result = index == _tmp8_;
	_g_free0 (text);
	return result;
}

static gboolean
string_get_next_char (const gchar* self,
                      gint* index,
                      gunichar* c)
{
	gunichar _vala_c = 0U;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_vala_c = g_utf8_get_char (((gchar*) self) + (*index));
	if (_vala_c != ((gunichar) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_utf8_next_char (((gchar*) self) + (*index));
		*index = (gint) (_tmp0_ - ((gchar*) self));
		result = TRUE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	} else {
		result = FALSE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	}
}

static gboolean
dc_message_row_consume_emoji_sequence (const gchar* text,
                                       gint* index)
{
	gunichar c = 0U;
	gunichar _tmp0_ = 0U;
	gboolean _tmp1_;
	gboolean result;
	g_return_val_if_fail (text != NULL, FALSE);
	_tmp1_ = string_get_next_char (text, index, &_tmp0_);
	c = _tmp0_;
	if (!_tmp1_) {
		result = FALSE;
		return result;
	}
	if (dc_message_row_is_keycap_base (c)) {
		gboolean _tmp2_;
		dc_message_row_consume_variation_selectors (text, index);
		_tmp2_ = dc_message_row_consume_char (text, index, (gunichar) 0x20e3);
		result = _tmp2_;
		return result;
	}
	if (dc_message_row_is_regional_indicator (c)) {
		gunichar _tmp3_ = 0U;
		gboolean _tmp4_;
		_tmp4_ = string_get_next_char (text, index, &_tmp3_);
		c = _tmp3_;
		if (!_tmp4_) {
			result = FALSE;
			return result;
		}
		result = dc_message_row_is_regional_indicator (c);
		return result;
	}
	if (!dc_message_row_is_emoji_base (c)) {
		result = FALSE;
		return result;
	}
	dc_message_row_consume_emoji_modifiers (text, index);
	while (TRUE) {
		gboolean _tmp5_;
		gunichar _tmp6_ = 0U;
		gboolean _tmp7_;
		_tmp5_ = dc_message_row_consume_char (text, index, (gunichar) 0x200d);
		if (!_tmp5_) {
			break;
		}
		_tmp7_ = string_get_next_char (text, index, &_tmp6_);
		c = _tmp6_;
		if (!_tmp7_) {
			result = FALSE;
			return result;
		}
		if (!dc_message_row_is_emoji_base (c)) {
			result = FALSE;
			return result;
		}
		dc_message_row_consume_emoji_modifiers (text, index);
	}
	result = TRUE;
	return result;
}

static gboolean
dc_message_row_consume_char (const gchar* text,
                             gint* index,
                             gunichar expected)
{
	gint next = 0;
	gunichar c = 0U;
	gunichar _tmp0_ = 0U;
	gboolean _tmp1_;
	gboolean result;
	g_return_val_if_fail (text != NULL, FALSE);
	next = *index;
	_tmp1_ = string_get_next_char (text, &next, &_tmp0_);
	c = _tmp0_;
	if (!_tmp1_) {
		result = FALSE;
		return result;
	}
	if (c != expected) {
		result = FALSE;
		return result;
	}
	*index = next;
	result = TRUE;
	return result;
}

static void
dc_message_row_consume_emoji_modifiers (const gchar* text,
                                        gint* index)
{
	g_return_if_fail (text != NULL);
	while (TRUE) {
		gboolean _tmp0_ = FALSE;
		gboolean _tmp1_;
		_tmp1_ = dc_message_row_consume_variation_selectors (text, index);
		if (_tmp1_) {
			_tmp0_ = TRUE;
		} else {
			gboolean _tmp2_;
			_tmp2_ = dc_message_row_consume_emoji_modifier (text, index);
			_tmp0_ = _tmp2_;
		}
		if (!_tmp0_) {
			break;
		}
	}
	dc_message_row_consume_tag_sequence (text, index);
}

static gboolean
dc_message_row_consume_variation_selectors (const gchar* text,
                                            gint* index)
{
	gboolean consumed = FALSE;
	gboolean result;
	g_return_val_if_fail (text != NULL, FALSE);
	consumed = FALSE;
	while (TRUE) {
		gint next = 0;
		gunichar c = 0U;
		gunichar _tmp0_ = 0U;
		gboolean _tmp1_;
		gboolean _tmp2_ = FALSE;
		next = *index;
		_tmp1_ = string_get_next_char (text, &next, &_tmp0_);
		c = _tmp0_;
		if (!_tmp1_) {
			result = consumed;
			return result;
		}
		if (c != ((gunichar) 0xfe0e)) {
			_tmp2_ = c != ((gunichar) 0xfe0f);
		} else {
			_tmp2_ = FALSE;
		}
		if (_tmp2_) {
			result = consumed;
			return result;
		}
		*index = next;
		consumed = TRUE;
	}
}

static gboolean
dc_message_row_consume_emoji_modifier (const gchar* text,
                                       gint* index)
{
	gint next = 0;
	gunichar c = 0U;
	gunichar _tmp0_ = 0U;
	gboolean _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean result;
	g_return_val_if_fail (text != NULL, FALSE);
	next = *index;
	_tmp1_ = string_get_next_char (text, &next, &_tmp0_);
	c = _tmp0_;
	if (!_tmp1_) {
		result = FALSE;
		return result;
	}
	if (c < ((gunichar) 0x1f3fb)) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = c > ((gunichar) 0x1f3ff);
	}
	if (_tmp2_) {
		result = FALSE;
		return result;
	}
	*index = next;
	result = TRUE;
	return result;
}

static void
dc_message_row_consume_tag_sequence (const gchar* text,
                                     gint* index)
{
	gint before = 0;
	gint next = 0;
	gunichar c = 0U;
	gboolean has_tag = FALSE;
	gboolean _tmp3_ = FALSE;
	g_return_if_fail (text != NULL);
	before = *index;
	next = *index;
	has_tag = FALSE;
	while (TRUE) {
		gunichar _tmp0_ = 0U;
		gboolean _tmp1_;
		gboolean _tmp2_ = FALSE;
		_tmp1_ = string_get_next_char (text, &next, &_tmp0_);
		c = _tmp0_;
		if (!_tmp1_) {
			break;
		}
		if (c < ((gunichar) 0xe0020)) {
			_tmp2_ = TRUE;
		} else {
			_tmp2_ = c > ((gunichar) 0xe007e);
		}
		if (_tmp2_) {
			break;
		}
		*index = next;
		has_tag = TRUE;
	}
	if (has_tag) {
		gboolean _tmp4_;
		_tmp4_ = dc_message_row_consume_char (text, index, (gunichar) 0xe007f);
		_tmp3_ = _tmp4_;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		return;
	}
	*index = before;
}

static gboolean
dc_message_row_is_keycap_base (gunichar c)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean result;
	if (c == ((gunichar) 0x23)) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = c == ((gunichar) 0x2a);
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp2_ = FALSE;
		if (c >= ((gunichar) 0x30)) {
			_tmp2_ = c <= ((gunichar) 0x39);
		} else {
			_tmp2_ = FALSE;
		}
		_tmp0_ = _tmp2_;
	}
	result = _tmp0_;
	return result;
}

static gboolean
dc_message_row_is_regional_indicator (gunichar c)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	if (c >= ((gunichar) 0x1f1e6)) {
		_tmp0_ = c <= ((gunichar) 0x1f1ff);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static gboolean
dc_message_row_is_emoji_base (gunichar c)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp12_ = FALSE;
	gboolean _tmp13_ = FALSE;
	gboolean _tmp14_ = FALSE;
	gboolean _tmp15_ = FALSE;
	gboolean _tmp16_ = FALSE;
	gboolean _tmp17_ = FALSE;
	gboolean _tmp18_ = FALSE;
	gboolean _tmp19_ = FALSE;
	gboolean _tmp20_ = FALSE;
	gboolean _tmp21_ = FALSE;
	gboolean _tmp22_ = FALSE;
	gboolean _tmp23_ = FALSE;
	gboolean _tmp24_ = FALSE;
	gboolean _tmp25_ = FALSE;
	gboolean _tmp26_ = FALSE;
	gboolean result;
	if (c == ((gunichar) 0x00a9)) {
		_tmp26_ = TRUE;
	} else {
		_tmp26_ = c == ((gunichar) 0x00ae);
	}
	if (_tmp26_) {
		_tmp25_ = TRUE;
	} else {
		_tmp25_ = c == ((gunichar) 0x203c);
	}
	if (_tmp25_) {
		_tmp24_ = TRUE;
	} else {
		_tmp24_ = c == ((gunichar) 0x2049);
	}
	if (_tmp24_) {
		_tmp23_ = TRUE;
	} else {
		_tmp23_ = c == ((gunichar) 0x2122);
	}
	if (_tmp23_) {
		_tmp22_ = TRUE;
	} else {
		_tmp22_ = c == ((gunichar) 0x2139);
	}
	if (_tmp22_) {
		_tmp21_ = TRUE;
	} else {
		gboolean _tmp27_ = FALSE;
		if (c >= ((gunichar) 0x2194)) {
			_tmp27_ = c <= ((gunichar) 0x21aa);
		} else {
			_tmp27_ = FALSE;
		}
		_tmp21_ = _tmp27_;
	}
	if (_tmp21_) {
		_tmp20_ = TRUE;
	} else {
		_tmp20_ = c == ((gunichar) 0x231a);
	}
	if (_tmp20_) {
		_tmp19_ = TRUE;
	} else {
		_tmp19_ = c == ((gunichar) 0x231b);
	}
	if (_tmp19_) {
		_tmp18_ = TRUE;
	} else {
		_tmp18_ = c == ((gunichar) 0x2328);
	}
	if (_tmp18_) {
		_tmp17_ = TRUE;
	} else {
		_tmp17_ = c == ((gunichar) 0x23cf);
	}
	if (_tmp17_) {
		_tmp16_ = TRUE;
	} else {
		gboolean _tmp28_ = FALSE;
		if (c >= ((gunichar) 0x23e9)) {
			_tmp28_ = c <= ((gunichar) 0x23f3);
		} else {
			_tmp28_ = FALSE;
		}
		_tmp16_ = _tmp28_;
	}
	if (_tmp16_) {
		_tmp15_ = TRUE;
	} else {
		gboolean _tmp29_ = FALSE;
		if (c >= ((gunichar) 0x23f8)) {
			_tmp29_ = c <= ((gunichar) 0x23fa);
		} else {
			_tmp29_ = FALSE;
		}
		_tmp15_ = _tmp29_;
	}
	if (_tmp15_) {
		_tmp14_ = TRUE;
	} else {
		_tmp14_ = c == ((gunichar) 0x24c2);
	}
	if (_tmp14_) {
		_tmp13_ = TRUE;
	} else {
		_tmp13_ = c == ((gunichar) 0x25aa);
	}
	if (_tmp13_) {
		_tmp12_ = TRUE;
	} else {
		_tmp12_ = c == ((gunichar) 0x25ab);
	}
	if (_tmp12_) {
		_tmp11_ = TRUE;
	} else {
		_tmp11_ = c == ((gunichar) 0x25b6);
	}
	if (_tmp11_) {
		_tmp10_ = TRUE;
	} else {
		_tmp10_ = c == ((gunichar) 0x25c0);
	}
	if (_tmp10_) {
		_tmp9_ = TRUE;
	} else {
		gboolean _tmp30_ = FALSE;
		if (c >= ((gunichar) 0x25fb)) {
			_tmp30_ = c <= ((gunichar) 0x25fe);
		} else {
			_tmp30_ = FALSE;
		}
		_tmp9_ = _tmp30_;
	}
	if (_tmp9_) {
		_tmp8_ = TRUE;
	} else {
		gboolean _tmp31_ = FALSE;
		if (c >= ((gunichar) 0x2600)) {
			_tmp31_ = c <= ((gunichar) 0x27bf);
		} else {
			_tmp31_ = FALSE;
		}
		_tmp8_ = _tmp31_;
	}
	if (_tmp8_) {
		_tmp7_ = TRUE;
	} else {
		_tmp7_ = c == ((gunichar) 0x2934);
	}
	if (_tmp7_) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = c == ((gunichar) 0x2935);
	}
	if (_tmp6_) {
		_tmp5_ = TRUE;
	} else {
		gboolean _tmp32_ = FALSE;
		if (c >= ((gunichar) 0x2b05)) {
			_tmp32_ = c <= ((gunichar) 0x2b55);
		} else {
			_tmp32_ = FALSE;
		}
		_tmp5_ = _tmp32_;
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = c == ((gunichar) 0x3030);
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = c == ((gunichar) 0x303d);
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = c == ((gunichar) 0x3297);
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = c == ((gunichar) 0x3299);
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp33_ = FALSE;
		if (c >= ((gunichar) 0x1f000)) {
			_tmp33_ = c <= ((gunichar) 0x1faff);
		} else {
			_tmp33_ = FALSE;
		}
		_tmp0_ = _tmp33_;
	}
	result = _tmp0_;
	return result;
}

/** Reaction badge bar, or null when the message has no reactions. */
static GtkBox*
dc_message_row_build_reactions_box (DcMessage* msg)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkBox* box = NULL;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar** _tmp12_;
	gchar** _tmp13_;
	GtkBox* result;
	g_return_val_if_fail (msg != NULL, NULL);
	_tmp1_ = dc_message_get_reactions (msg);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		_tmp3_ = dc_message_get_reactions (msg);
		_tmp4_ = _tmp3_;
		_tmp5_ = strlen (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_ == 0;
	}
	if (_tmp0_) {
		result = NULL;
		return result;
	}
	_tmp7_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
	g_object_ref_sink (_tmp7_);
	box = _tmp7_;
	_tmp8_ = box;
	gtk_widget_add_css_class ((GtkWidget*) _tmp8_, "reaction-bar");
	_tmp9_ = box;
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_START);
	_tmp10_ = dc_message_get_reactions (msg);
	_tmp11_ = _tmp10_;
	_tmp13_ = _tmp12_ = g_strsplit (_tmp11_, ",", 0);
	{
		gchar** part_collection = NULL;
		gint part_collection_length1 = 0;
		gint _part_collection_size_ = 0;
		gint part_it = 0;
		part_collection = _tmp13_;
		part_collection_length1 = _vala_array_length (_tmp12_);
		for (part_it = 0; part_it < part_collection_length1; part_it = part_it + 1) {
			gchar* _tmp14_;
			gchar* part = NULL;
			_tmp14_ = g_strdup (part_collection[part_it]);
			part = _tmp14_;
			{
				gchar** kv = NULL;
				const gchar* _tmp15_;
				gchar** _tmp16_;
				gchar** _tmp17_;
				gint kv_length1;
				gint _kv_size_;
				gchar** _tmp18_;
				gint _tmp18__length1;
				gchar* _tmp19_ = NULL;
				gchar** _tmp20_;
				gint _tmp20__length1;
				const gchar* _tmp21_;
				GtkLabel* badge = NULL;
				GtkLabel* _tmp30_;
				GtkLabel* _tmp31_;
				GtkBox* _tmp32_;
				GtkLabel* _tmp33_;
				_tmp15_ = part;
				_tmp17_ = _tmp16_ = g_strsplit (_tmp15_, ":", 2);
				kv = _tmp17_;
				kv_length1 = _vala_array_length (_tmp16_);
				_kv_size_ = kv_length1;
				_tmp18_ = kv;
				_tmp18__length1 = kv_length1;
				if (_tmp18__length1 < 2) {
					kv = (_vala_array_free (kv, kv_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (part);
					continue;
				}
				_tmp20_ = kv;
				_tmp20__length1 = kv_length1;
				_tmp21_ = _tmp20_[1];
				if (g_strcmp0 (_tmp21_, "1") == 0) {
					gchar** _tmp22_;
					gint _tmp22__length1;
					const gchar* _tmp23_;
					gchar* _tmp24_;
					_tmp22_ = kv;
					_tmp22__length1 = kv_length1;
					_tmp23_ = _tmp22_[0];
					_tmp24_ = g_strdup (_tmp23_);
					_g_free0 (_tmp19_);
					_tmp19_ = _tmp24_;
				} else {
					gchar** _tmp25_;
					gint _tmp25__length1;
					const gchar* _tmp26_;
					gchar** _tmp27_;
					gint _tmp27__length1;
					const gchar* _tmp28_;
					gchar* _tmp29_;
					_tmp25_ = kv;
					_tmp25__length1 = kv_length1;
					_tmp26_ = _tmp25_[0];
					_tmp27_ = kv;
					_tmp27__length1 = kv_length1;
					_tmp28_ = _tmp27_[1];
					_tmp29_ = g_strdup_printf ("%s %s", _tmp26_, _tmp28_);
					_g_free0 (_tmp19_);
					_tmp19_ = _tmp29_;
				}
				_tmp30_ = (GtkLabel*) gtk_label_new (_tmp19_);
				g_object_ref_sink (_tmp30_);
				badge = _tmp30_;
				_tmp31_ = badge;
				gtk_widget_add_css_class ((GtkWidget*) _tmp31_, "reaction-badge");
				_tmp32_ = box;
				_tmp33_ = badge;
				gtk_box_append (_tmp32_, (GtkWidget*) _tmp33_);
				_g_object_unref0 (badge);
				_g_free0 (_tmp19_);
				kv = (_vala_array_free (kv, kv_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (part);
			}
		}
		part_collection = (_vala_array_free (part_collection, part_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	result = box;
	return result;
}

static gchar*
dc_message_row_format_timestamp (gint64 ts)
{
	GDateTime* dt = NULL;
	GDateTime* _tmp1_;
	GDateTime* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	if (ts <= ((gint64) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("");
		result = _tmp0_;
		return result;
	}
	_tmp1_ = g_date_time_new_from_unix_local (ts);
	dt = _tmp1_;
	_tmp2_ = dt;
	_tmp3_ = g_date_time_format (_tmp2_, "%H:%M");
	result = _tmp3_;
	_g_date_time_unref0 (dt);
	return result;
}

/** Build a centered date-separator label, styled like info rows. */
GtkWidget*
dc_message_row_build_date_separator (gint64 ts)
{
	GtkLabel* label = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkWidget* result;
	_tmp0_ = dc_message_row_format_date_label (ts);
	_tmp1_ = _tmp0_;
	_tmp2_ = (GtkLabel*) gtk_label_new (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	label = _tmp3_;
	gtk_widget_add_css_class ((GtkWidget*) label, "dim-label");
	gtk_widget_add_css_class ((GtkWidget*) label, "caption");
	gtk_widget_set_hexpand ((GtkWidget*) label, TRUE);
	gtk_widget_set_halign ((GtkWidget*) label, GTK_ALIGN_CENTER);
	gtk_label_set_justify (label, GTK_JUSTIFY_CENTER);
	gtk_widget_set_margin_top ((GtkWidget*) label, 8);
	gtk_widget_set_margin_bottom ((GtkWidget*) label, 4);
	result = (GtkWidget*) label;
	return result;
}

/** Format a timestamp as a date label: "3 June" (current year) or
            "3 June 2023" (other years). */
gchar*
dc_message_row_format_date_label (gint64 ts)
{
	GDateTime* dt = NULL;
	GDateTime* _tmp1_;
	GDateTime* now = NULL;
	GDateTime* _tmp2_;
	gint day = 0;
	GDateTime* _tmp3_;
	gchar* month = NULL;
	GDateTime* _tmp4_;
	gchar* _tmp5_;
	GDateTime* _tmp6_;
	GDateTime* _tmp7_;
	const gchar* _tmp10_;
	GDateTime* _tmp11_;
	gchar* _tmp12_;
	gchar* result;
	if (ts <= ((gint64) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("");
		result = _tmp0_;
		return result;
	}
	_tmp1_ = g_date_time_new_from_unix_local (ts);
	dt = _tmp1_;
	_tmp2_ = g_date_time_new_now_local ();
	now = _tmp2_;
	_tmp3_ = dt;
	day = g_date_time_get_day_of_month (_tmp3_);
	_tmp4_ = dt;
	_tmp5_ = g_date_time_format (_tmp4_, "%B");
	month = _tmp5_;
	_tmp6_ = dt;
	_tmp7_ = now;
	if (g_date_time_get_year (_tmp6_) == g_date_time_get_year (_tmp7_)) {
		const gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp8_ = month;
		_tmp9_ = g_strdup_printf ("%d %s", day, _tmp8_);
		result = _tmp9_;
		_g_free0 (month);
		_g_date_time_unref0 (now);
		_g_date_time_unref0 (dt);
		return result;
	}
	_tmp10_ = month;
	_tmp11_ = dt;
	_tmp12_ = g_strdup_printf ("%d %s %d", day, _tmp10_, g_date_time_get_year (_tmp11_));
	result = _tmp12_;
	_g_free0 (month);
	_g_date_time_unref0 (now);
	_g_date_time_unref0 (dt);
	return result;
}

/** True when two unix timestamps fall on the same calendar day. */
gboolean
dc_message_row_same_day (gint64 ts1,
                         gint64 ts2)
{
	gboolean _tmp0_ = FALSE;
	GDateTime* dt1 = NULL;
	GDateTime* _tmp1_;
	GDateTime* dt2 = NULL;
	GDateTime* _tmp2_;
	gboolean _tmp3_ = FALSE;
	GDateTime* _tmp4_;
	GDateTime* _tmp5_;
	gboolean result;
	if (ts1 <= ((gint64) 0)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = ts2 <= ((gint64) 0);
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp1_ = g_date_time_new_from_unix_local (ts1);
	dt1 = _tmp1_;
	_tmp2_ = g_date_time_new_from_unix_local (ts2);
	dt2 = _tmp2_;
	_tmp4_ = dt1;
	_tmp5_ = dt2;
	if (g_date_time_get_year (_tmp4_) == g_date_time_get_year (_tmp5_)) {
		GDateTime* _tmp6_;
		GDateTime* _tmp7_;
		_tmp6_ = dt1;
		_tmp7_ = dt2;
		_tmp3_ = g_date_time_get_day_of_year (_tmp6_) == g_date_time_get_day_of_year (_tmp7_);
	} else {
		_tmp3_ = FALSE;
	}
	result = _tmp3_;
	_g_date_time_unref0 (dt2);
	_g_date_time_unref0 (dt1);
	return result;
}

gint
dc_message_row_get_message_id (DcMessageRow* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_message_id;
	return result;
}

static void
dc_message_row_set_message_id (DcMessageRow* self,
                               gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_message_row_get_message_id (self);
	if (old_value != value) {
		self->priv->_message_id = value;
		g_object_notify_by_pspec ((GObject *) self, dc_message_row_properties[DC_MESSAGE_ROW_MESSAGE_ID_PROPERTY]);
	}
}

gboolean
dc_message_row_get_is_outgoing (DcMessageRow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_outgoing;
	return result;
}

static void
dc_message_row_set_is_outgoing (DcMessageRow* self,
                                gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_message_row_get_is_outgoing (self);
	if (old_value != value) {
		self->priv->_is_outgoing = value;
		g_object_notify_by_pspec ((GObject *) self, dc_message_row_properties[DC_MESSAGE_ROW_IS_OUTGOING_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_VOID__INT_BOOLEAN (GClosure * closure,
                                           GValue * return_value,
                                           guint n_param_values,
                                           const GValue * param_values,
                                           gpointer invocation_hint,
                                           gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__INT_BOOLEAN) (gpointer data1, gint arg_1, gboolean arg_2, gpointer data2);
	register GMarshalFunc_VOID__INT_BOOLEAN 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_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_boolean (param_values + 2), data2);
}

static gchar**
_vala_array_dup3 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static DcMessageRowMarkdownTableRow*
dc_message_row_markdown_table_row_construct (GType object_type,
                                             gchar** cells,
                                             gint cells_length1,
                                             gboolean header)
{
	DcMessageRowMarkdownTableRow* self = NULL;
	gchar** _tmp0_;
	gint _tmp0__length1;
	self = (DcMessageRowMarkdownTableRow*) g_type_create_instance (object_type);
	_tmp0_ = (cells != NULL) ? _vala_array_dup3 (cells, cells_length1) : cells;
	_tmp0__length1 = cells_length1;
	self->cells = (_vala_array_free (self->cells, self->cells_length1, (GDestroyNotify) g_free), NULL);
	self->cells = _tmp0_;
	self->cells_length1 = _tmp0__length1;
	self->_cells_size_ = self->cells_length1;
	self->header = header;
	return self;
}

static DcMessageRowMarkdownTableRow*
dc_message_row_markdown_table_row_new (gchar** cells,
                                       gint cells_length1,
                                       gboolean header)
{
	return dc_message_row_markdown_table_row_construct (DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW, cells, cells_length1, header);
}

static void
dc_message_row_value_markdown_table_row_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dc_message_row_value_markdown_table_row_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dc_message_row_markdown_table_row_unref (value->data[0].v_pointer);
	}
}

static void
dc_message_row_value_markdown_table_row_copy_value (const GValue* src_value,
                                                    GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dc_message_row_markdown_table_row_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dc_message_row_value_markdown_table_row_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dc_message_row_value_markdown_table_row_collect_value (GValue* value,
                                                       guint n_collect_values,
                                                       GTypeCValue* collect_values,
                                                       guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DcMessageRowMarkdownTableRow * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dc_message_row_markdown_table_row_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dc_message_row_value_markdown_table_row_lcopy_value (const GValue* value,
                                                     guint n_collect_values,
                                                     GTypeCValue* collect_values,
                                                     guint collect_flags)
{
	DcMessageRowMarkdownTableRow ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dc_message_row_markdown_table_row_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
dc_message_row_param_spec_markdown_table_row (const gchar* name,
                                              const gchar* nick,
                                              const gchar* blurb,
                                              GType object_type,
                                              GParamFlags flags)
{
	DcMessageRowParamSpecMarkdownTableRow* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
dc_message_row_value_get_markdown_table_row (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW), NULL);
	return value->data[0].v_pointer;
}

static void
dc_message_row_value_set_markdown_table_row (GValue* value,
                                             gpointer v_object)
{
	DcMessageRowMarkdownTableRow * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dc_message_row_markdown_table_row_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_message_row_markdown_table_row_unref (old);
	}
}

static void
dc_message_row_value_take_markdown_table_row (GValue* value,
                                              gpointer v_object)
{
	DcMessageRowMarkdownTableRow * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_message_row_markdown_table_row_unref (old);
	}
}

static void
dc_message_row_markdown_table_row_class_init (DcMessageRowMarkdownTableRowClass * klass,
                                              gpointer klass_data)
{
	dc_message_row_markdown_table_row_parent_class = g_type_class_peek_parent (klass);
	((DcMessageRowMarkdownTableRowClass *) klass)->finalize = dc_message_row_markdown_table_row_finalize;
}

static void
dc_message_row_markdown_table_row_instance_init (DcMessageRowMarkdownTableRow * self,
                                                 gpointer klass)
{
	self->ref_count = 1;
}

static void
dc_message_row_markdown_table_row_finalize (DcMessageRowMarkdownTableRow * obj)
{
	DcMessageRowMarkdownTableRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_ROW, DcMessageRowMarkdownTableRow);
	g_signal_handlers_destroy (self);
	self->cells = (_vala_array_free (self->cells, self->cells_length1, (GDestroyNotify) g_free), NULL);
}

static GType
dc_message_row_markdown_table_row_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dc_message_row_value_markdown_table_row_init, dc_message_row_value_markdown_table_row_free_value, dc_message_row_value_markdown_table_row_copy_value, dc_message_row_value_markdown_table_row_peek_pointer, "p", dc_message_row_value_markdown_table_row_collect_value, "p", dc_message_row_value_markdown_table_row_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DcMessageRowMarkdownTableRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_message_row_markdown_table_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcMessageRowMarkdownTableRow), 0, (GInstanceInitFunc) dc_message_row_markdown_table_row_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dc_message_row_markdown_table_row_type_id;
	dc_message_row_markdown_table_row_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DcMessageRowMarkdownTableRow", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return dc_message_row_markdown_table_row_type_id;
}

static GType
dc_message_row_markdown_table_row_get_type (void)
{
	static volatile gsize dc_message_row_markdown_table_row_type_id__once = 0;
	if (g_once_init_enter (&dc_message_row_markdown_table_row_type_id__once)) {
		GType dc_message_row_markdown_table_row_type_id;
		dc_message_row_markdown_table_row_type_id = dc_message_row_markdown_table_row_get_type_once ();
		g_once_init_leave (&dc_message_row_markdown_table_row_type_id__once, dc_message_row_markdown_table_row_type_id);
	}
	return dc_message_row_markdown_table_row_type_id__once;
}

static gpointer
dc_message_row_markdown_table_row_ref (gpointer instance)
{
	DcMessageRowMarkdownTableRow * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
dc_message_row_markdown_table_row_unref (gpointer instance)
{
	DcMessageRowMarkdownTableRow * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DC_MESSAGE_ROW_MARKDOWN_TABLE_ROW_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
_dc_message_row_markdown_table_row_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (dc_message_row_markdown_table_row_unref (var), NULL));
}

static DcMessageRowMarkdownTableBlock*
dc_message_row_markdown_table_block_construct (GType object_type,
                                               gint columns)
{
	DcMessageRowMarkdownTableBlock* self = NULL;
	gint* _tmp0_;
	self = (DcMessageRowMarkdownTableBlock*) g_type_create_instance (object_type);
	_tmp0_ = g_new0 (gint, columns);
	self->aligns = (g_free (self->aligns), NULL);
	self->aligns = _tmp0_;
	self->aligns_length1 = columns;
	self->_aligns_size_ = self->aligns_length1;
	return self;
}

static DcMessageRowMarkdownTableBlock*
dc_message_row_markdown_table_block_new (gint columns)
{
	return dc_message_row_markdown_table_block_construct (DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK, columns);
}

static void
dc_message_row_value_markdown_table_block_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dc_message_row_value_markdown_table_block_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dc_message_row_markdown_table_block_unref (value->data[0].v_pointer);
	}
}

static void
dc_message_row_value_markdown_table_block_copy_value (const GValue* src_value,
                                                      GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dc_message_row_markdown_table_block_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dc_message_row_value_markdown_table_block_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dc_message_row_value_markdown_table_block_collect_value (GValue* value,
                                                         guint n_collect_values,
                                                         GTypeCValue* collect_values,
                                                         guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DcMessageRowMarkdownTableBlock * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dc_message_row_markdown_table_block_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dc_message_row_value_markdown_table_block_lcopy_value (const GValue* value,
                                                       guint n_collect_values,
                                                       GTypeCValue* collect_values,
                                                       guint collect_flags)
{
	DcMessageRowMarkdownTableBlock ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dc_message_row_markdown_table_block_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
dc_message_row_param_spec_markdown_table_block (const gchar* name,
                                                const gchar* nick,
                                                const gchar* blurb,
                                                GType object_type,
                                                GParamFlags flags)
{
	DcMessageRowParamSpecMarkdownTableBlock* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
dc_message_row_value_get_markdown_table_block (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK), NULL);
	return value->data[0].v_pointer;
}

static void
dc_message_row_value_set_markdown_table_block (GValue* value,
                                               gpointer v_object)
{
	DcMessageRowMarkdownTableBlock * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dc_message_row_markdown_table_block_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_message_row_markdown_table_block_unref (old);
	}
}

static void
dc_message_row_value_take_markdown_table_block (GValue* value,
                                                gpointer v_object)
{
	DcMessageRowMarkdownTableBlock * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_message_row_markdown_table_block_unref (old);
	}
}

static void
dc_message_row_markdown_table_block_class_init (DcMessageRowMarkdownTableBlockClass * klass,
                                                gpointer klass_data)
{
	dc_message_row_markdown_table_block_parent_class = g_type_class_peek_parent (klass);
	((DcMessageRowMarkdownTableBlockClass *) klass)->finalize = dc_message_row_markdown_table_block_finalize;
}

static void
dc_message_row_markdown_table_block_instance_init (DcMessageRowMarkdownTableBlock * self,
                                                   gpointer klass)
{
	GPtrArray* _tmp0_;
	_tmp0_ = g_ptr_array_new_full ((guint) 0, _dc_message_row_markdown_table_row_unref0_);
	self->rows = _tmp0_;
	self->ref_count = 1;
}

static void
dc_message_row_markdown_table_block_finalize (DcMessageRowMarkdownTableBlock * obj)
{
	DcMessageRowMarkdownTableBlock * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_MESSAGE_ROW_TYPE_MARKDOWN_TABLE_BLOCK, DcMessageRowMarkdownTableBlock);
	g_signal_handlers_destroy (self);
	_g_ptr_array_unref0 (self->rows);
	self->aligns = (g_free (self->aligns), NULL);
}

static GType
dc_message_row_markdown_table_block_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dc_message_row_value_markdown_table_block_init, dc_message_row_value_markdown_table_block_free_value, dc_message_row_value_markdown_table_block_copy_value, dc_message_row_value_markdown_table_block_peek_pointer, "p", dc_message_row_value_markdown_table_block_collect_value, "p", dc_message_row_value_markdown_table_block_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DcMessageRowMarkdownTableBlockClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_message_row_markdown_table_block_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcMessageRowMarkdownTableBlock), 0, (GInstanceInitFunc) dc_message_row_markdown_table_block_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dc_message_row_markdown_table_block_type_id;
	dc_message_row_markdown_table_block_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DcMessageRowMarkdownTableBlock", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return dc_message_row_markdown_table_block_type_id;
}

static GType
dc_message_row_markdown_table_block_get_type (void)
{
	static volatile gsize dc_message_row_markdown_table_block_type_id__once = 0;
	if (g_once_init_enter (&dc_message_row_markdown_table_block_type_id__once)) {
		GType dc_message_row_markdown_table_block_type_id;
		dc_message_row_markdown_table_block_type_id = dc_message_row_markdown_table_block_get_type_once ();
		g_once_init_leave (&dc_message_row_markdown_table_block_type_id__once, dc_message_row_markdown_table_block_type_id);
	}
	return dc_message_row_markdown_table_block_type_id__once;
}

static gpointer
dc_message_row_markdown_table_block_ref (gpointer instance)
{
	DcMessageRowMarkdownTableBlock * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
dc_message_row_markdown_table_block_unref (gpointer instance)
{
	DcMessageRowMarkdownTableBlock * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DC_MESSAGE_ROW_MARKDOWN_TABLE_BLOCK_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
dc_message_row_class_init (DcMessageRowClass * klass,
                           gpointer klass_data)
{
	dc_message_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcMessageRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_message_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_message_row_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_message_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_MESSAGE_ROW_MESSAGE_ID_PROPERTY, dc_message_row_properties[DC_MESSAGE_ROW_MESSAGE_ID_PROPERTY] = g_param_spec_int ("message-id", "message-id", "message-id", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_MESSAGE_ROW_IS_OUTGOING_PROPERTY, dc_message_row_properties[DC_MESSAGE_ROW_IS_OUTGOING_PROPERTY] = g_param_spec_boolean ("is-outgoing", "is-outgoing", "is-outgoing", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	dc_message_row_signals[DC_MESSAGE_ROW_QUOTE_CLICKED_SIGNAL] = g_signal_new ("quote-clicked", DC_TYPE_MESSAGE_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
	dc_message_row_signals[DC_MESSAGE_ROW_FULL_MESSAGE_REQUESTED_SIGNAL] = g_signal_new ("full-message-requested", DC_TYPE_MESSAGE_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
	dc_message_row_signals[DC_MESSAGE_ROW_SELECTION_TOGGLED_SIGNAL] = g_signal_new ("selection-toggled", DC_TYPE_MESSAGE_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_BOOLEAN, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_BOOLEAN);
}

static void
dc_message_row_instance_init (DcMessageRow * self,
                              gpointer klass)
{
	self->priv = dc_message_row_get_instance_private (self);
}

static void
dc_message_row_finalize (GObject * obj)
{
	DcMessageRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_MESSAGE_ROW, DcMessageRow);
	G_OBJECT_CLASS (dc_message_row_parent_class)->finalize (obj);
}

/**
     * A single message bubble in the conversation view.
     * Incoming messages are left-aligned, outgoing messages right-aligned.
     */
static GType
dc_message_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcMessageRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_message_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcMessageRow), 0, (GInstanceInitFunc) dc_message_row_instance_init, NULL };
	GType dc_message_row_type_id;
	dc_message_row_type_id = g_type_register_static (gtk_box_get_type (), "DcMessageRow", &g_define_type_info, 0);
	DcMessageRow_private_offset = g_type_add_instance_private (dc_message_row_type_id, sizeof (DcMessageRowPrivate));
	return dc_message_row_type_id;
}

GType
dc_message_row_get_type (void)
{
	static volatile gsize dc_message_row_type_id__once = 0;
	if (g_once_init_enter (&dc_message_row_type_id__once)) {
		GType dc_message_row_type_id;
		dc_message_row_type_id = dc_message_row_get_type_once ();
		g_once_init_leave (&dc_message_row_type_id__once, dc_message_row_type_id);
	}
	return dc_message_row_type_id__once;
}

static void
_vala_dc_message_row_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec)
{
	DcMessageRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_MESSAGE_ROW, DcMessageRow);
	switch (property_id) {
		case DC_MESSAGE_ROW_MESSAGE_ID_PROPERTY:
		g_value_set_int (value, dc_message_row_get_message_id (self));
		break;
		case DC_MESSAGE_ROW_IS_OUTGOING_PROPERTY:
		g_value_set_boolean (value, dc_message_row_get_is_outgoing (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_message_row_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec)
{
	DcMessageRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_MESSAGE_ROW, DcMessageRow);
	switch (property_id) {
		case DC_MESSAGE_ROW_MESSAGE_ID_PROPERTY:
		dc_message_row_set_message_id (self, g_value_get_int (value));
		break;
		case DC_MESSAGE_ROW_IS_OUTGOING_PROPERTY:
		dc_message_row_set_is_outgoing (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;
}

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

