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

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

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define DC_TYPE_CHAT_ROW (dc_chat_row_get_type ())
#define DC_CHAT_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CHAT_ROW, DcChatRow))
#define DC_CHAT_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CHAT_ROW, DcChatRowClass))
#define DC_IS_CHAT_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CHAT_ROW))
#define DC_IS_CHAT_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CHAT_ROW))
#define DC_CHAT_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CHAT_ROW, DcChatRowClass))

typedef struct _DcChatRow DcChatRow;
typedef struct _DcChatRowClass DcChatRowClass;
typedef struct _DcChatRowPrivate DcChatRowPrivate;
enum  {
	DC_CHAT_ROW_0_PROPERTY,
	DC_CHAT_ROW_CHAT_ID_PROPERTY,
	DC_CHAT_ROW_NUM_PROPERTIES
};
static GParamSpec* dc_chat_row_properties[DC_CHAT_ROW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define DC_TYPE_CHAT_ENTRY (dc_chat_entry_get_type ())
#define DC_CHAT_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CHAT_ENTRY, DcChatEntry))
#define DC_CHAT_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CHAT_ENTRY, DcChatEntryClass))
#define DC_IS_CHAT_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CHAT_ENTRY))
#define DC_IS_CHAT_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CHAT_ENTRY))
#define DC_CHAT_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CHAT_ENTRY, DcChatEntryClass))

typedef struct _DcChatEntry DcChatEntry;
typedef struct _DcChatEntryClass DcChatEntryClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

#define DC_TYPE_CHAT_CONTEXT_MENU (dc_chat_context_menu_get_type ())
#define DC_CHAT_CONTEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CHAT_CONTEXT_MENU, DcChatContextMenu))
#define DC_CHAT_CONTEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CHAT_CONTEXT_MENU, DcChatContextMenuClass))
#define DC_IS_CHAT_CONTEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CHAT_CONTEXT_MENU))
#define DC_IS_CHAT_CONTEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CHAT_CONTEXT_MENU))
#define DC_CHAT_CONTEXT_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CHAT_CONTEXT_MENU, DcChatContextMenuClass))

typedef struct _DcChatContextMenu DcChatContextMenu;
typedef struct _DcChatContextMenuClass DcChatContextMenuClass;
typedef struct _DcChatContextMenuPrivate DcChatContextMenuPrivate;

#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_TYPE_RPC_CLIENT (dc_rpc_client_get_type ())
#define DC_RPC_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_RPC_CLIENT, DcRpcClient))
#define DC_RPC_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_RPC_CLIENT, DcRpcClientClass))
#define DC_IS_RPC_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_RPC_CLIENT))
#define DC_IS_RPC_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_RPC_CLIENT))
#define DC_RPC_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_RPC_CLIENT, DcRpcClientClass))

typedef struct _DcRpcClient DcRpcClient;
typedef struct _DcRpcClientClass DcRpcClientClass;
enum  {
	DC_CHAT_CONTEXT_MENU_0_PROPERTY,
	DC_CHAT_CONTEXT_MENU_NUM_PROPERTIES
};
static GParamSpec* dc_chat_context_menu_properties[DC_CHAT_CONTEXT_MENU_NUM_PROPERTIES];
typedef struct _Block10Data Block10Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DcChatContextMenuTogglePinData DcChatContextMenuTogglePinData;
typedef struct _Block11Data Block11Data;

#define DC_TYPE_CHAT_INFO_DIALOG (dc_chat_info_dialog_get_type ())
#define DC_CHAT_INFO_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CHAT_INFO_DIALOG, DcChatInfoDialog))
#define DC_CHAT_INFO_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CHAT_INFO_DIALOG, DcChatInfoDialogClass))
#define DC_IS_CHAT_INFO_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CHAT_INFO_DIALOG))
#define DC_IS_CHAT_INFO_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CHAT_INFO_DIALOG))
#define DC_CHAT_INFO_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CHAT_INFO_DIALOG, DcChatInfoDialogClass))

typedef struct _DcChatInfoDialog DcChatInfoDialog;
typedef struct _DcChatInfoDialogClass DcChatInfoDialogClass;
typedef struct _DcChatContextMenuShowInfoData DcChatContextMenuShowInfoData;
typedef struct _Block12Data Block12Data;
typedef void (*DcVoidFunc) (gpointer user_data);
typedef struct _DcChatContextMenuConfirmDeleteData DcChatContextMenuConfirmDeleteData;
typedef struct _DcChatContextMenuDoDeleteData DcChatContextMenuDoDeleteData;

struct _DcChatRow {
	GtkBox parent_instance;
	DcChatRowPrivate * priv;
};

struct _DcChatRowClass {
	GtkBoxClass parent_class;
};

struct _DcChatRowPrivate {
	gint _chat_id;
	GtkLabel* name_label;
	GtkLabel* preview_label;
	GtkLabel* time_label;
	GtkLabel* badge_label;
};

struct _DcChatContextMenu {
	GObject parent_instance;
	DcChatContextMenuPrivate * priv;
};

struct _DcChatContextMenuClass {
	GObjectClass parent_class;
};

struct _DcChatContextMenuPrivate {
	DcWindow* window;
	DcRpcClient* rpc;
	GListStore* chat_store;
};

struct _Block10Data {
	int _ref_count_;
	DcChatContextMenu* self;
	gboolean is_pinned;
	GtkPopover* popover;
	gint chat_id;
};

struct _DcChatContextMenuTogglePinData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcChatContextMenu* self;
	gint chat_id;
	gboolean currently_pinned;
	const gchar* _tmp0_;
	gchar* visibility;
	gchar* _tmp1_;
	DcRpcClient* _tmp2_;
	DcWindow* _tmp3_;
	GError* e;
	DcWindow* _tmp4_;
	GError* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GError* _inner_error0_;
};

struct _Block11Data {
	int _ref_count_;
	DcChatContextMenu* self;
	gint chat_id;
	gpointer _async_data_;
};

struct _DcChatContextMenuShowInfoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcChatContextMenu* self;
	gint chat_id;
	Block11Data* _data11_;
	DcChatInfoDialog* dialog;
	DcRpcClient* _tmp0_;
	DcChatInfoDialog* _tmp1_;
	DcWindow* _tmp2_;
};

struct _Block12Data {
	int _ref_count_;
	DcChatContextMenu* self;
	gint chat_id;
	gpointer _async_data_;
};

struct _DcChatContextMenuConfirmDeleteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcChatContextMenu* self;
	gint chat_id;
	Block12Data* _data12_;
	gchar* chat_name;
	gchar* _tmp0_;
	DcChatEntry* entry;
	GListStore* _tmp1_;
	DcChatEntry* _tmp2_;
	DcChatEntry* _tmp3_;
	DcChatEntry* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	DcWindow* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
};

struct _DcChatContextMenuDoDeleteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcChatContextMenu* self;
	gint chat_id;
	DcRpcClient* _tmp0_;
	DcWindow* _tmp1_;
	DcWindow* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	DcWindow* _tmp5_;
	DcWindow* _tmp6_;
	GError* e;
	DcWindow* _tmp7_;
	GError* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GError* _inner_error0_;
};

static gint DcChatRow_private_offset;
static gpointer dc_chat_row_parent_class = NULL;
static gint DcChatContextMenu_private_offset;
static gpointer dc_chat_context_menu_parent_class = NULL;

VALA_EXTERN GType dc_chat_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatRow, g_object_unref)
VALA_EXTERN GType dc_chat_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatEntry, g_object_unref)
VALA_EXTERN DcChatRow* dc_chat_row_new (DcChatEntry* entry);
VALA_EXTERN DcChatRow* dc_chat_row_construct (GType object_type,
                                  DcChatEntry* entry);
VALA_EXTERN gint dc_chat_entry_get_id (DcChatEntry* self);
static void dc_chat_row_set_chat_id (DcChatRow* self,
                              gint value);
VALA_EXTERN const gchar* dc_chat_entry_get_name (DcChatEntry* self);
VALA_EXTERN GdkTexture* dc_load_avatar (const gchar* path);
VALA_EXTERN const gchar* dc_chat_entry_get_avatar_path (DcChatEntry* self);
VALA_EXTERN gint dc_chat_entry_get_unread_count (DcChatEntry* self);
VALA_EXTERN gboolean dc_chat_entry_get_is_contact_request (DcChatEntry* self);
VALA_EXTERN gboolean dc_chat_entry_get_is_muted (DcChatEntry* self);
VALA_EXTERN gboolean dc_chat_entry_get_is_pinned (DcChatEntry* self);
static gchar* dc_chat_row_format_time (gint64 timestamp);
VALA_EXTERN gint64 dc_chat_entry_get_timestamp (DcChatEntry* self);
static gchar* dc_chat_row_format_preview (DcChatEntry* entry);
VALA_EXTERN const gchar* dc_chat_entry_get_last_message (DcChatEntry* self);
VALA_EXTERN const gchar* dc_chat_entry_get_summary_prefix (DcChatEntry* self);
VALA_EXTERN gint dc_chat_row_get_chat_id (DcChatRow* self);
static void dc_chat_row_finalize (GObject * obj);
static GType dc_chat_row_get_type_once (void);
static void _vala_dc_chat_row_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_dc_chat_row_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec);
VALA_EXTERN GType dc_chat_context_menu_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatContextMenu, g_object_unref)
VALA_EXTERN GType dc_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcWindow, g_object_unref)
VALA_EXTERN GType dc_rpc_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRpcClient, g_object_unref)
VALA_EXTERN DcChatContextMenu* dc_chat_context_menu_new (DcWindow* window,
                                             DcRpcClient* rpc,
                                             GListStore* chat_store);
VALA_EXTERN DcChatContextMenu* dc_chat_context_menu_construct (GType object_type,
                                                   DcWindow* window,
                                                   DcRpcClient* rpc,
                                                   GListStore* chat_store);
VALA_EXTERN void dc_chat_context_menu_show (DcChatContextMenu* self,
                                gint chat_id,
                                gdouble x,
                                gdouble y,
                                GtkWidget* parent);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
VALA_EXTERN DcChatEntry* dc_find_chat_entry (GListStore* store,
                                 gint chat_id);
static GtkButton* dc_chat_context_menu_make_menu_button (const gchar* label);
static void __lambda61_ (Block10Data* _data10_);
static void dc_chat_context_menu_toggle_pin (DcChatContextMenu* self,
                                      gint chat_id,
                                      gboolean currently_pinned,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);
static void dc_chat_context_menu_toggle_pin_finish (DcChatContextMenu* self,
                                             GAsyncResult* _res_);
static void ___lambda61__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda62_ (Block10Data* _data10_);
static void dc_chat_context_menu_show_info (DcChatContextMenu* self,
                                     gint chat_id,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static void dc_chat_context_menu_show_info_finish (DcChatContextMenu* self,
                                            GAsyncResult* _res_);
static void ___lambda62__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda81_ (Block10Data* _data10_);
static void dc_chat_context_menu_confirm_delete (DcChatContextMenu* self,
                                          gint chat_id,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static void dc_chat_context_menu_confirm_delete_finish (DcChatContextMenu* self,
                                                 GAsyncResult* _res_);
static void ___lambda81__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda83_ (Block10Data* _data10_);
static void ___lambda83__gtk_popover_closed (GtkPopover* _sender,
                                      gpointer self);
static void dc_chat_context_menu_toggle_pin_data_free (gpointer _data);
static gboolean dc_chat_context_menu_toggle_pin_co (DcChatContextMenuTogglePinData* _data_);
VALA_EXTERN void dc_rpc_client_set_chat_visibility (DcRpcClient* self,
                                        gint chat_id,
                                        const gchar* visibility,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_set_chat_visibility_finish (DcRpcClient* self,
                                               GAsyncResult* _res_,
                                               GError** error);
static void dc_chat_context_menu_toggle_pin_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_);
VALA_EXTERN void dc_window_load_chats (DcWindow* self,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_);
VALA_EXTERN void dc_window_load_chats_finish (DcWindow* self,
                                  GAsyncResult* _res_);
VALA_EXTERN void dc_window_show_toast (DcWindow* self,
                           const gchar* message);
static void dc_chat_context_menu_show_info_data_free (gpointer _data);
static gboolean dc_chat_context_menu_show_info_co (DcChatContextMenuShowInfoData* _data_);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
VALA_EXTERN GType dc_chat_info_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatInfoDialog, g_object_unref)
VALA_EXTERN DcChatInfoDialog* dc_chat_info_dialog_new (DcRpcClient* rpc,
                                           gint chat_id);
VALA_EXTERN DcChatInfoDialog* dc_chat_info_dialog_construct (GType object_type,
                                                 DcRpcClient* rpc,
                                                 gint chat_id);
static void __lambda79_ (DcChatContextMenu* self,
                  gint cid);
VALA_EXTERN gint dc_window_get_current_chat_id (DcWindow* self);
VALA_EXTERN void dc_window_clear_chat_view (DcWindow* self);
VALA_EXTERN void dc_window_request_reload_chats (DcWindow* self);
static void ___lambda79__dc_chat_info_dialog_chat_deleted (DcChatInfoDialog* _sender,
                                                    gint chat_id,
                                                    gpointer self);
static void __lambda80_ (Block11Data* _data11_);
VALA_EXTERN void dc_window_request_messages_reload (DcWindow* self);
static void ___lambda80__dc_chat_info_dialog_chat_changed (DcChatInfoDialog* _sender,
                                                    gpointer self);
static void dc_chat_context_menu_confirm_delete_data_free (gpointer _data);
static gboolean dc_chat_context_menu_confirm_delete_co (DcChatContextMenuConfirmDeleteData* _data_);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
VALA_EXTERN void dc_confirm_delete_options (GtkWidget* parent,
                                const gchar* title,
                                const gchar* body,
                                DcVoidFunc on_delete_for_me,
                                gpointer on_delete_for_me_target,
                                GDestroyNotify on_delete_for_me_target_destroy_notify,
                                DcVoidFunc on_delete_for_everyone,
                                gpointer on_delete_for_everyone_target,
                                GDestroyNotify on_delete_for_everyone_target_destroy_notify);
static void __lambda82_ (Block12Data* _data12_);
static void dc_chat_context_menu_do_delete (DcChatContextMenu* self,
                                     gint chat_id,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static void dc_chat_context_menu_do_delete_finish (DcChatContextMenu* self,
                                            GAsyncResult* _res_);
static void ___lambda82__dc_void_func (gpointer self);
static void dc_chat_context_menu_do_delete_data_free (gpointer _data);
static gboolean dc_chat_context_menu_do_delete_co (DcChatContextMenuDoDeleteData* _data_);
VALA_EXTERN void dc_rpc_client_delete_chat (DcRpcClient* self,
                                gint chat_id,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_delete_chat_finish (DcRpcClient* self,
                                       GAsyncResult* _res_,
                                       GError** error);
static void dc_chat_context_menu_do_delete_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
static void dc_chat_context_menu_finalize (GObject * obj);
static GType dc_chat_context_menu_get_type_once (void);

static inline gpointer
dc_chat_row_get_instance_private (DcChatRow* self)
{
	return G_STRUCT_MEMBER_P (self, DcChatRow_private_offset);
}

DcChatRow*
dc_chat_row_construct (GType object_type,
                       DcChatEntry* entry)
{
	DcChatRow * self = NULL;
	gint _tmp0_;
	gint _tmp1_;
	AdwAvatar* avatar = NULL;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	AdwAvatar* _tmp4_;
	AdwAvatar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	GdkTexture* _tmp8_;
	GdkTexture* _tmp9_;
	AdwAvatar* _tmp10_;
	GtkBox* mid = NULL;
	GtkBox* _tmp11_;
	GtkBox* _tmp12_;
	GtkBox* _tmp13_;
	GtkBox* top = NULL;
	GtkBox* _tmp14_;
	gboolean _tmp15_ = FALSE;
	gint _tmp16_;
	gint _tmp17_;
	gboolean has_unread = FALSE;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	GtkLabel* _tmp29_;
	GtkLabel* _tmp30_;
	GtkLabel* _tmp32_;
	GtkLabel* _tmp33_;
	GtkLabel* _tmp34_;
	GtkLabel* _tmp35_;
	GtkBox* _tmp36_;
	GtkLabel* _tmp37_;
	gboolean _tmp38_;
	gboolean _tmp39_;
	gint64 _tmp45_;
	gint64 _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	GtkLabel* _tmp49_;
	GtkLabel* _tmp50_;
	GtkLabel* _tmp51_;
	GtkBox* _tmp52_;
	GtkLabel* _tmp53_;
	GtkBox* _tmp54_;
	GtkBox* _tmp55_;
	GtkBox* bot = NULL;
	GtkBox* _tmp56_;
	gchar* _tmp57_;
	gchar* _tmp58_;
	GtkLabel* _tmp59_;
	GtkLabel* _tmp61_;
	GtkLabel* _tmp62_;
	GtkLabel* _tmp63_;
	GtkLabel* _tmp64_;
	GtkLabel* _tmp65_;
	GtkBox* _tmp66_;
	GtkLabel* _tmp67_;
	gboolean _tmp68_;
	gboolean _tmp69_;
	GtkBox* _tmp89_;
	GtkBox* _tmp90_;
	GtkBox* _tmp91_;
	g_return_val_if_fail (entry != NULL, NULL);
	self = (DcChatRow*) g_object_new (object_type, "orientation", GTK_ORIENTATION_HORIZONTAL, "spacing", 10, NULL);
	_tmp0_ = dc_chat_entry_get_id (entry);
	_tmp1_ = _tmp0_;
	dc_chat_row_set_chat_id (self, _tmp1_);
	gtk_widget_add_css_class ((GtkWidget*) self, "chat-row");
	gtk_widget_set_margin_start ((GtkWidget*) self, 8);
	gtk_widget_set_margin_end ((GtkWidget*) self, 8);
	gtk_widget_set_margin_top ((GtkWidget*) self, 4);
	gtk_widget_set_margin_bottom ((GtkWidget*) self, 4);
	_tmp2_ = dc_chat_entry_get_name (entry);
	_tmp3_ = _tmp2_;
	_tmp4_ = (AdwAvatar*) adw_avatar_new (40, _tmp3_, TRUE);
	g_object_ref_sink (_tmp4_);
	avatar = _tmp4_;
	_tmp5_ = avatar;
	_tmp6_ = dc_chat_entry_get_avatar_path (entry);
	_tmp7_ = _tmp6_;
	_tmp8_ = dc_load_avatar (_tmp7_);
	_tmp9_ = _tmp8_;
	adw_avatar_set_custom_image (_tmp5_, (GdkPaintable*) _tmp9_);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = avatar;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp10_);
	_tmp11_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
	g_object_ref_sink (_tmp11_);
	mid = _tmp11_;
	_tmp12_ = mid;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp12_, TRUE);
	_tmp13_ = mid;
	gtk_widget_set_valign ((GtkWidget*) _tmp13_, GTK_ALIGN_CENTER);
	_tmp14_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp14_);
	top = _tmp14_;
	_tmp16_ = dc_chat_entry_get_unread_count (entry);
	_tmp17_ = _tmp16_;
	if (_tmp17_ > 0) {
		gboolean _tmp18_;
		gboolean _tmp19_;
		_tmp18_ = dc_chat_entry_get_is_contact_request (entry);
		_tmp19_ = _tmp18_;
		_tmp15_ = !_tmp19_;
	} else {
		_tmp15_ = FALSE;
	}
	has_unread = _tmp15_;
	if (has_unread) {
		GtkLabel* dot = NULL;
		GtkLabel* _tmp20_;
		const gchar* _tmp21_ = NULL;
		gboolean _tmp22_;
		gboolean _tmp23_;
		GtkLabel* _tmp24_;
		GtkBox* _tmp25_;
		GtkLabel* _tmp26_;
		_tmp20_ = (GtkLabel*) gtk_label_new ("\u25CF");
		g_object_ref_sink (_tmp20_);
		dot = _tmp20_;
		_tmp22_ = dc_chat_entry_get_is_muted (entry);
		_tmp23_ = _tmp22_;
		if (_tmp23_) {
			_tmp21_ = "unread-dot-muted";
		} else {
			_tmp21_ = "unread-dot";
		}
		_tmp24_ = dot;
		gtk_widget_add_css_class ((GtkWidget*) _tmp24_, _tmp21_);
		_tmp25_ = top;
		_tmp26_ = dot;
		gtk_box_append (_tmp25_, (GtkWidget*) _tmp26_);
		_g_object_unref0 (dot);
	}
	_tmp27_ = dc_chat_entry_get_name (entry);
	_tmp28_ = _tmp27_;
	_tmp29_ = (GtkLabel*) gtk_label_new (_tmp28_);
	g_object_ref_sink (_tmp29_);
	_g_object_unref0 (self->priv->name_label);
	self->priv->name_label = _tmp29_;
	_tmp30_ = self->priv->name_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp30_, "heading");
	if (has_unread) {
		GtkLabel* _tmp31_;
		_tmp31_ = self->priv->name_label;
		gtk_widget_add_css_class ((GtkWidget*) _tmp31_, "unread-name");
	}
	_tmp32_ = self->priv->name_label;
	gtk_label_set_ellipsize (_tmp32_, PANGO_ELLIPSIZE_END);
	_tmp33_ = self->priv->name_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp33_, TRUE);
	_tmp34_ = self->priv->name_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp34_, GTK_ALIGN_START);
	_tmp35_ = self->priv->name_label;
	gtk_label_set_xalign (_tmp35_, (gfloat) 0);
	_tmp36_ = top;
	_tmp37_ = self->priv->name_label;
	gtk_box_append (_tmp36_, (GtkWidget*) _tmp37_);
	_tmp38_ = dc_chat_entry_get_is_pinned (entry);
	_tmp39_ = _tmp38_;
	if (_tmp39_) {
		GtkLabel* pin_label = NULL;
		GtkLabel* _tmp40_;
		GtkLabel* _tmp41_;
		GtkLabel* _tmp42_;
		GtkBox* _tmp43_;
		GtkLabel* _tmp44_;
		_tmp40_ = (GtkLabel*) gtk_label_new ("📌");
		g_object_ref_sink (_tmp40_);
		pin_label = _tmp40_;
		_tmp41_ = pin_label;
		gtk_widget_add_css_class ((GtkWidget*) _tmp41_, "dim-label");
		_tmp42_ = pin_label;
		gtk_widget_add_css_class ((GtkWidget*) _tmp42_, "caption");
		_tmp43_ = top;
		_tmp44_ = pin_label;
		gtk_box_append (_tmp43_, (GtkWidget*) _tmp44_);
		_g_object_unref0 (pin_label);
	}
	_tmp45_ = dc_chat_entry_get_timestamp (entry);
	_tmp46_ = _tmp45_;
	_tmp47_ = dc_chat_row_format_time (_tmp46_);
	_tmp48_ = _tmp47_;
	_tmp49_ = (GtkLabel*) gtk_label_new (_tmp48_);
	g_object_ref_sink (_tmp49_);
	_g_object_unref0 (self->priv->time_label);
	self->priv->time_label = _tmp49_;
	_g_free0 (_tmp48_);
	_tmp50_ = self->priv->time_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp50_, "dim-label");
	_tmp51_ = self->priv->time_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp51_, "caption");
	_tmp52_ = top;
	_tmp53_ = self->priv->time_label;
	gtk_box_append (_tmp52_, (GtkWidget*) _tmp53_);
	_tmp54_ = mid;
	_tmp55_ = top;
	gtk_box_append (_tmp54_, (GtkWidget*) _tmp55_);
	_tmp56_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp56_);
	bot = _tmp56_;
	_tmp57_ = dc_chat_row_format_preview (entry);
	_tmp58_ = _tmp57_;
	_tmp59_ = (GtkLabel*) gtk_label_new (_tmp58_);
	g_object_ref_sink (_tmp59_);
	_g_object_unref0 (self->priv->preview_label);
	self->priv->preview_label = _tmp59_;
	_g_free0 (_tmp58_);
	if (!has_unread) {
		GtkLabel* _tmp60_;
		_tmp60_ = self->priv->preview_label;
		gtk_widget_add_css_class ((GtkWidget*) _tmp60_, "dim-label");
	}
	_tmp61_ = self->priv->preview_label;
	gtk_label_set_ellipsize (_tmp61_, PANGO_ELLIPSIZE_END);
	_tmp62_ = self->priv->preview_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp62_, TRUE);
	_tmp63_ = self->priv->preview_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp63_, GTK_ALIGN_START);
	_tmp64_ = self->priv->preview_label;
	gtk_label_set_xalign (_tmp64_, (gfloat) 0);
	_tmp65_ = self->priv->preview_label;
	gtk_label_set_max_width_chars (_tmp65_, 30);
	_tmp66_ = bot;
	_tmp67_ = self->priv->preview_label;
	gtk_box_append (_tmp66_, (GtkWidget*) _tmp67_);
	_tmp68_ = dc_chat_entry_get_is_contact_request (entry);
	_tmp69_ = _tmp68_;
	if (_tmp69_) {
		GtkLabel* _tmp70_;
		GtkLabel* _tmp71_;
		GtkLabel* _tmp72_;
		GtkLabel* _tmp73_;
		GtkBox* _tmp74_;
		GtkLabel* _tmp75_;
		_tmp70_ = (GtkLabel*) gtk_label_new ("Request");
		g_object_ref_sink (_tmp70_);
		_g_object_unref0 (self->priv->badge_label);
		self->priv->badge_label = _tmp70_;
		_tmp71_ = self->priv->badge_label;
		gtk_widget_add_css_class ((GtkWidget*) _tmp71_, "contact-request-badge");
		_tmp72_ = self->priv->badge_label;
		gtk_widget_set_halign ((GtkWidget*) _tmp72_, GTK_ALIGN_END);
		_tmp73_ = self->priv->badge_label;
		gtk_widget_set_valign ((GtkWidget*) _tmp73_, GTK_ALIGN_CENTER);
		_tmp74_ = bot;
		_tmp75_ = self->priv->badge_label;
		gtk_box_append (_tmp74_, (GtkWidget*) _tmp75_);
	} else {
		if (has_unread) {
			gint _tmp76_;
			gint _tmp77_;
			gchar* _tmp78_;
			gchar* _tmp79_;
			GtkLabel* _tmp80_;
			const gchar* _tmp81_ = NULL;
			gboolean _tmp82_;
			gboolean _tmp83_;
			GtkLabel* _tmp84_;
			GtkLabel* _tmp85_;
			GtkLabel* _tmp86_;
			GtkBox* _tmp87_;
			GtkLabel* _tmp88_;
			_tmp76_ = dc_chat_entry_get_unread_count (entry);
			_tmp77_ = _tmp76_;
			_tmp78_ = g_strdup_printf ("%i", _tmp77_);
			_tmp79_ = _tmp78_;
			_tmp80_ = (GtkLabel*) gtk_label_new (_tmp79_);
			g_object_ref_sink (_tmp80_);
			_g_object_unref0 (self->priv->badge_label);
			self->priv->badge_label = _tmp80_;
			_g_free0 (_tmp79_);
			_tmp82_ = dc_chat_entry_get_is_muted (entry);
			_tmp83_ = _tmp82_;
			if (_tmp83_) {
				_tmp81_ = "unread-badge-muted";
			} else {
				_tmp81_ = "unread-badge";
			}
			_tmp84_ = self->priv->badge_label;
			gtk_widget_add_css_class ((GtkWidget*) _tmp84_, _tmp81_);
			_tmp85_ = self->priv->badge_label;
			gtk_widget_set_halign ((GtkWidget*) _tmp85_, GTK_ALIGN_END);
			_tmp86_ = self->priv->badge_label;
			gtk_widget_set_valign ((GtkWidget*) _tmp86_, GTK_ALIGN_CENTER);
			_tmp87_ = bot;
			_tmp88_ = self->priv->badge_label;
			gtk_box_append (_tmp87_, (GtkWidget*) _tmp88_);
		}
	}
	_tmp89_ = mid;
	_tmp90_ = bot;
	gtk_box_append (_tmp89_, (GtkWidget*) _tmp90_);
	_tmp91_ = mid;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp91_);
	_g_object_unref0 (bot);
	_g_object_unref0 (top);
	_g_object_unref0 (mid);
	_g_object_unref0 (avatar);
	return self;
}

DcChatRow*
dc_chat_row_new (DcChatEntry* entry)
{
	return dc_chat_row_construct (DC_TYPE_CHAT_ROW, entry);
}

static gchar*
dc_chat_row_format_preview (DcChatEntry* entry)
{
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* preview = NULL;
	gchar* _tmp3_;
	gboolean _tmp4_ = FALSE;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* result;
	g_return_val_if_fail (entry != NULL, NULL);
	_tmp1_ = dc_chat_entry_get_last_message (entry);
	_tmp2_ = _tmp1_;
	_tmp0_ = _tmp2_;
	if (_tmp0_ == NULL) {
		_tmp0_ = "";
	}
	_tmp3_ = g_strdup (_tmp0_);
	preview = _tmp3_;
	_tmp5_ = dc_chat_entry_get_summary_prefix (entry);
	_tmp6_ = _tmp5_;
	if (_tmp6_ != NULL) {
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		_tmp7_ = dc_chat_entry_get_summary_prefix (entry);
		_tmp8_ = _tmp7_;
		_tmp9_ = strlen (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp4_ = _tmp10_ > 0;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		const gchar* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		gchar* _tmp20_;
		_tmp11_ = preview;
		_tmp12_ = strlen (_tmp11_);
		_tmp13_ = _tmp12_;
		if (_tmp13_ > 0) {
			const gchar* _tmp14_;
			const gchar* _tmp15_;
			const gchar* _tmp16_;
			gchar* _tmp17_;
			_tmp14_ = dc_chat_entry_get_summary_prefix (entry);
			_tmp15_ = _tmp14_;
			_tmp16_ = preview;
			_tmp17_ = g_strdup_printf ("%s: %s", _tmp15_, _tmp16_);
			result = _tmp17_;
			_g_free0 (preview);
			return result;
		}
		_tmp18_ = dc_chat_entry_get_summary_prefix (entry);
		_tmp19_ = _tmp18_;
		_tmp20_ = g_strdup (_tmp19_);
		result = _tmp20_;
		_g_free0 (preview);
		return result;
	}
	result = preview;
	return result;
}

static gchar*
dc_chat_row_format_time (gint64 timestamp)
{
	GDateTime* now = NULL;
	GDateTime* _tmp1_;
	GDateTime* dt = NULL;
	GDateTime* _tmp2_;
	gboolean _tmp3_ = FALSE;
	GDateTime* _tmp4_;
	GDateTime* _tmp5_;
	gint diff = 0;
	GDateTime* _tmp10_;
	GDateTime* _tmp11_;
	GDateTime* _tmp14_;
	gchar* _tmp15_;
	gchar* result;
	if (timestamp <= ((gint64) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("");
		result = _tmp0_;
		return result;
	}
	_tmp1_ = g_date_time_new_now_local ();
	now = _tmp1_;
	_tmp2_ = g_date_time_new_from_unix_local (timestamp);
	dt = _tmp2_;
	_tmp4_ = now;
	_tmp5_ = dt;
	if (g_date_time_get_year (_tmp4_) == g_date_time_get_year (_tmp5_)) {
		GDateTime* _tmp6_;
		GDateTime* _tmp7_;
		_tmp6_ = now;
		_tmp7_ = dt;
		_tmp3_ = g_date_time_get_day_of_year (_tmp6_) == g_date_time_get_day_of_year (_tmp7_);
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		GDateTime* _tmp8_;
		gchar* _tmp9_;
		_tmp8_ = dt;
		_tmp9_ = g_date_time_format (_tmp8_, "%H:%M");
		result = _tmp9_;
		_g_date_time_unref0 (dt);
		_g_date_time_unref0 (now);
		return result;
	}
	_tmp10_ = now;
	_tmp11_ = dt;
	diff = (gint) (g_date_time_to_unix (_tmp10_) - g_date_time_to_unix (_tmp11_));
	if (diff < (7 * 86400)) {
		GDateTime* _tmp12_;
		gchar* _tmp13_;
		_tmp12_ = dt;
		_tmp13_ = g_date_time_format (_tmp12_, "%a");
		result = _tmp13_;
		_g_date_time_unref0 (dt);
		_g_date_time_unref0 (now);
		return result;
	}
	_tmp14_ = dt;
	_tmp15_ = g_date_time_format (_tmp14_, "%d/%m/%y");
	result = _tmp15_;
	_g_date_time_unref0 (dt);
	_g_date_time_unref0 (now);
	return result;
}

gint
dc_chat_row_get_chat_id (DcChatRow* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_chat_id;
	return result;
}

static void
dc_chat_row_set_chat_id (DcChatRow* self,
                         gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_chat_row_get_chat_id (self);
	if (old_value != value) {
		self->priv->_chat_id = value;
		g_object_notify_by_pspec ((GObject *) self, dc_chat_row_properties[DC_CHAT_ROW_CHAT_ID_PROPERTY]);
	}
}

static void
dc_chat_row_class_init (DcChatRowClass * klass,
                        gpointer klass_data)
{
	dc_chat_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcChatRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_chat_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_chat_row_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_chat_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_CHAT_ROW_CHAT_ID_PROPERTY, dc_chat_row_properties[DC_CHAT_ROW_CHAT_ID_PROPERTY] = g_param_spec_int ("chat-id", "chat-id", "chat-id", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dc_chat_row_instance_init (DcChatRow * self,
                           gpointer klass)
{
	self->priv = dc_chat_row_get_instance_private (self);
	self->priv->badge_label = NULL;
}

static void
dc_chat_row_finalize (GObject * obj)
{
	DcChatRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_CHAT_ROW, DcChatRow);
	_g_object_unref0 (self->priv->name_label);
	_g_object_unref0 (self->priv->preview_label);
	_g_object_unref0 (self->priv->time_label);
	_g_object_unref0 (self->priv->badge_label);
	G_OBJECT_CLASS (dc_chat_row_parent_class)->finalize (obj);
}

/**
     * A single row in the chat list sidebar.
     * Shows avatar placeholder, chat name, last message preview, time, and unread badge.
     */
static GType
dc_chat_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcChatRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_chat_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcChatRow), 0, (GInstanceInitFunc) dc_chat_row_instance_init, NULL };
	GType dc_chat_row_type_id;
	dc_chat_row_type_id = g_type_register_static (gtk_box_get_type (), "DcChatRow", &g_define_type_info, 0);
	DcChatRow_private_offset = g_type_add_instance_private (dc_chat_row_type_id, sizeof (DcChatRowPrivate));
	return dc_chat_row_type_id;
}

GType
dc_chat_row_get_type (void)
{
	static volatile gsize dc_chat_row_type_id__once = 0;
	if (g_once_init_enter (&dc_chat_row_type_id__once)) {
		GType dc_chat_row_type_id;
		dc_chat_row_type_id = dc_chat_row_get_type_once ();
		g_once_init_leave (&dc_chat_row_type_id__once, dc_chat_row_type_id);
	}
	return dc_chat_row_type_id__once;
}

static void
_vala_dc_chat_row_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	DcChatRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_CHAT_ROW, DcChatRow);
	switch (property_id) {
		case DC_CHAT_ROW_CHAT_ID_PROPERTY:
		g_value_set_int (value, dc_chat_row_get_chat_id (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_chat_row_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	DcChatRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_CHAT_ROW, DcChatRow);
	switch (property_id) {
		case DC_CHAT_ROW_CHAT_ID_PROPERTY:
		dc_chat_row_set_chat_id (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
dc_chat_context_menu_get_instance_private (DcChatContextMenu* self)
{
	return G_STRUCT_MEMBER_P (self, DcChatContextMenu_private_offset);
}

DcChatContextMenu*
dc_chat_context_menu_construct (GType object_type,
                                DcWindow* window,
                                DcRpcClient* rpc,
                                GListStore* chat_store)
{
	DcChatContextMenu * self = NULL;
	g_return_val_if_fail (window != NULL, NULL);
	g_return_val_if_fail (rpc != NULL, NULL);
	g_return_val_if_fail (chat_store != NULL, NULL);
	self = (DcChatContextMenu*) g_object_new (object_type, NULL);
	self->priv->window = window;
	self->priv->rpc = rpc;
	self->priv->chat_store = chat_store;
	return self;
}

DcChatContextMenu*
dc_chat_context_menu_new (DcWindow* window,
                          DcRpcClient* rpc,
                          GListStore* chat_store)
{
	return dc_chat_context_menu_construct (DC_TYPE_CHAT_CONTEXT_MENU, window, rpc, chat_store);
}

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		DcChatContextMenu* self;
		self = _data10_->self;
		_g_object_unref0 (_data10_->popover);
		_g_object_unref0 (self);
		g_slice_free (Block10Data, _data10_);
	}
}

static void
__lambda61_ (Block10Data* _data10_)
{
	DcChatContextMenu* self;
	GtkPopover* _tmp0_;
	self = _data10_->self;
	_tmp0_ = _data10_->popover;
	gtk_popover_popdown (_tmp0_);
	dc_chat_context_menu_toggle_pin (self, _data10_->chat_id, _data10_->is_pinned, NULL, NULL);
}

static void
___lambda61__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda61_ (self);
}

static void
__lambda62_ (Block10Data* _data10_)
{
	DcChatContextMenu* self;
	GtkPopover* _tmp0_;
	self = _data10_->self;
	_tmp0_ = _data10_->popover;
	gtk_popover_popdown (_tmp0_);
	dc_chat_context_menu_show_info (self, _data10_->chat_id, NULL, NULL);
}

static void
___lambda62__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda62_ (self);
}

static void
__lambda81_ (Block10Data* _data10_)
{
	DcChatContextMenu* self;
	GtkPopover* _tmp0_;
	self = _data10_->self;
	_tmp0_ = _data10_->popover;
	gtk_popover_popdown (_tmp0_);
	dc_chat_context_menu_confirm_delete (self, _data10_->chat_id, NULL, NULL);
}

static void
___lambda81__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda81_ (self);
}

static void
__lambda83_ (Block10Data* _data10_)
{
	DcChatContextMenu* self;
	GtkPopover* _tmp0_;
	self = _data10_->self;
	_tmp0_ = _data10_->popover;
	gtk_widget_unparent ((GtkWidget*) _tmp0_);
}

static void
___lambda83__gtk_popover_closed (GtkPopover* _sender,
                                 gpointer self)
{
	__lambda83_ (self);
}

void
dc_chat_context_menu_show (DcChatContextMenu* self,
                           gint chat_id,
                           gdouble x,
                           gdouble y,
                           GtkWidget* parent)
{
	Block10Data* _data10_;
	DcChatEntry* entry = NULL;
	GListStore* _tmp0_;
	DcChatEntry* _tmp1_;
	DcChatEntry* _tmp2_;
	GtkPopover* _tmp6_;
	GtkPopover* _tmp7_;
	GtkPopover* _tmp8_;
	GtkPopover* _tmp9_;
	GdkRectangle _tmp10_ = {0};
	GtkBox* box = NULL;
	GtkBox* _tmp11_;
	GtkBox* _tmp12_;
	const gchar* _tmp13_ = NULL;
	GtkButton* pin_btn = NULL;
	GtkButton* _tmp14_;
	GtkBox* _tmp15_;
	GtkButton* info_btn = NULL;
	GtkButton* _tmp16_;
	GtkBox* _tmp17_;
	GtkButton* del_btn = NULL;
	GtkButton* _tmp18_;
	GtkBox* _tmp19_;
	GtkPopover* _tmp20_;
	GtkBox* _tmp21_;
	GtkPopover* _tmp22_;
	GtkPopover* _tmp23_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (parent != NULL);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_data10_->self = g_object_ref (self);
	_data10_->chat_id = chat_id;
	_data10_->is_pinned = FALSE;
	_tmp0_ = self->priv->chat_store;
	_tmp1_ = dc_find_chat_entry (_tmp0_, _data10_->chat_id);
	entry = _tmp1_;
	_tmp2_ = entry;
	if (_tmp2_ != NULL) {
		DcChatEntry* _tmp3_;
		gboolean _tmp4_;
		gboolean _tmp5_;
		_tmp3_ = entry;
		_tmp4_ = dc_chat_entry_get_is_pinned (_tmp3_);
		_tmp5_ = _tmp4_;
		_data10_->is_pinned = _tmp5_;
	}
	_tmp6_ = (GtkPopover*) gtk_popover_new ();
	g_object_ref_sink (_tmp6_);
	_data10_->popover = _tmp6_;
	_tmp7_ = _data10_->popover;
	gtk_popover_set_has_arrow (_tmp7_, FALSE);
	_tmp8_ = _data10_->popover;
	gtk_widget_set_parent ((GtkWidget*) _tmp8_, parent);
	_tmp9_ = _data10_->popover;
	_tmp10_.x = (gint) x;
	_tmp10_.y = (gint) y;
	_tmp10_.width = 1;
	_tmp10_.height = 1;
	gtk_popover_set_pointing_to (_tmp9_, &_tmp10_);
	_tmp11_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp11_);
	box = _tmp11_;
	_tmp12_ = box;
	gtk_widget_add_css_class ((GtkWidget*) _tmp12_, "menu");
	if (_data10_->is_pinned) {
		_tmp13_ = "Unpin";
	} else {
		_tmp13_ = "Pin";
	}
	_tmp14_ = dc_chat_context_menu_make_menu_button (_tmp13_);
	pin_btn = _tmp14_;
	g_signal_connect_data (pin_btn, "clicked", (GCallback) ___lambda61__gtk_button_clicked, block10_data_ref (_data10_), (GClosureNotify) block10_data_unref, 0);
	_tmp15_ = box;
	gtk_box_append (_tmp15_, (GtkWidget*) pin_btn);
	_tmp16_ = dc_chat_context_menu_make_menu_button ("Chat Info");
	info_btn = _tmp16_;
	g_signal_connect_data (info_btn, "clicked", (GCallback) ___lambda62__gtk_button_clicked, block10_data_ref (_data10_), (GClosureNotify) block10_data_unref, 0);
	_tmp17_ = box;
	gtk_box_append (_tmp17_, (GtkWidget*) info_btn);
	_tmp18_ = dc_chat_context_menu_make_menu_button ("Delete…");
	del_btn = _tmp18_;
	g_signal_connect_data (del_btn, "clicked", (GCallback) ___lambda81__gtk_button_clicked, block10_data_ref (_data10_), (GClosureNotify) block10_data_unref, 0);
	_tmp19_ = box;
	gtk_box_append (_tmp19_, (GtkWidget*) del_btn);
	_tmp20_ = _data10_->popover;
	_tmp21_ = box;
	gtk_popover_set_child (_tmp20_, (GtkWidget*) _tmp21_);
	_tmp22_ = _data10_->popover;
	g_signal_connect_data (_tmp22_, "closed", (GCallback) ___lambda83__gtk_popover_closed, block10_data_ref (_data10_), (GClosureNotify) block10_data_unref, 0);
	_tmp23_ = _data10_->popover;
	gtk_popover_popup (_tmp23_);
	_g_object_unref0 (del_btn);
	_g_object_unref0 (info_btn);
	_g_object_unref0 (pin_btn);
	_g_object_unref0 (box);
	_g_object_unref0 (entry);
	block10_data_unref (_data10_);
	_data10_ = NULL;
}

static GtkButton*
dc_chat_context_menu_make_menu_button (const gchar* label)
{
	GtkButton* btn = NULL;
	GtkButton* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkButton* result;
	g_return_val_if_fail (label != NULL, NULL);
	_tmp0_ = (GtkButton*) gtk_button_new_with_label (label);
	g_object_ref_sink (_tmp0_);
	btn = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) btn, "flat");
	_tmp1_ = gtk_button_get_child (btn);
	_tmp2_ = _tmp1_;
	gtk_label_set_xalign (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_label_get_type (), GtkLabel), (gfloat) 0);
	_tmp3_ = gtk_button_get_child (btn);
	_tmp4_ = _tmp3_;
	gtk_widget_set_halign ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_label_get_type (), GtkLabel), GTK_ALIGN_START);
	result = btn;
	return result;
}

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

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

static void
dc_chat_context_menu_toggle_pin (DcChatContextMenu* self,
                                 gint chat_id,
                                 gboolean currently_pinned,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_)
{
	DcChatContextMenuTogglePinData* _data_;
	DcChatContextMenu* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcChatContextMenuTogglePinData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_chat_context_menu_toggle_pin_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->chat_id = chat_id;
	_data_->currently_pinned = currently_pinned;
	dc_chat_context_menu_toggle_pin_co (_data_);
}

static void
dc_chat_context_menu_toggle_pin_finish (DcChatContextMenu* self,
                                        GAsyncResult* _res_)
{
	DcChatContextMenuTogglePinData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_chat_context_menu_toggle_pin_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_)
{
	DcChatContextMenuTogglePinData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_chat_context_menu_toggle_pin_co (_data_);
}

static gboolean
dc_chat_context_menu_toggle_pin_co (DcChatContextMenuTogglePinData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		if (_data_->currently_pinned) {
			_data_->_tmp0_ = "Normal";
		} else {
			_data_->_tmp0_ = "Pinned";
		}
		_data_->_tmp1_ = g_strdup (_data_->_tmp0_);
		_data_->visibility = _data_->_tmp1_;
		_data_->_tmp2_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_set_chat_visibility (_data_->_tmp2_, _data_->chat_id, _data_->visibility, dc_chat_context_menu_toggle_pin_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_set_chat_visibility_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->visibility);
			goto __catch0_g_error;
		}
		_data_->_tmp3_ = _data_->self->priv->window;
		_data_->_state_ = 2;
		dc_window_load_chats (_data_->_tmp3_, dc_chat_context_menu_toggle_pin_ready, _data_);
		return FALSE;
		_state_2:
		dc_window_load_chats_finish (_data_->_tmp3_, _data_->_res_);
		_g_free0 (_data_->visibility);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp4_ = _data_->self->priv->window;
		_data_->_tmp5_ = _data_->e;
		_data_->_tmp6_ = _data_->_tmp5_->message;
		_data_->_tmp7_ = g_strconcat ("Failed to update pin: ", _data_->_tmp6_, NULL);
		_data_->_tmp8_ = _data_->_tmp7_;
		dc_window_show_toast (_data_->_tmp4_, _data_->_tmp8_);
		_g_free0 (_data_->_tmp8_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
dc_chat_context_menu_show_info (DcChatContextMenu* self,
                                gint chat_id,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	DcChatContextMenuShowInfoData* _data_;
	DcChatContextMenu* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcChatContextMenuShowInfoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_chat_context_menu_show_info_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->chat_id = chat_id;
	dc_chat_context_menu_show_info_co (_data_);
}

static void
dc_chat_context_menu_show_info_finish (DcChatContextMenu* self,
                                       GAsyncResult* _res_)
{
	DcChatContextMenuShowInfoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		DcChatContextMenu* self;
		self = _data11_->self;
		_g_object_unref0 (self);
		g_slice_free (Block11Data, _data11_);
	}
}

static void
__lambda79_ (DcChatContextMenu* self,
             gint cid)
{
	DcWindow* _tmp0_;
	DcWindow* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	DcWindow* _tmp5_;
	_tmp0_ = self->priv->window;
	dc_window_show_toast (_tmp0_, "Chat deleted");
	_tmp1_ = self->priv->window;
	_tmp2_ = dc_window_get_current_chat_id (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == cid) {
		DcWindow* _tmp4_;
		_tmp4_ = self->priv->window;
		dc_window_clear_chat_view (_tmp4_);
	}
	_tmp5_ = self->priv->window;
	dc_window_request_reload_chats (_tmp5_);
}

static void
___lambda79__dc_chat_info_dialog_chat_deleted (DcChatInfoDialog* _sender,
                                               gint chat_id,
                                               gpointer self)
{
	__lambda79_ ((DcChatContextMenu*) self, chat_id);
}

static void
__lambda80_ (Block11Data* _data11_)
{
	DcChatContextMenu* self;
	DcWindow* _tmp0_;
	DcWindow* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	self = _data11_->self;
	_tmp0_ = self->priv->window;
	dc_window_request_reload_chats (_tmp0_);
	_tmp1_ = self->priv->window;
	_tmp2_ = dc_window_get_current_chat_id (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == _data11_->chat_id) {
		DcWindow* _tmp4_;
		_tmp4_ = self->priv->window;
		dc_window_request_messages_reload (_tmp4_);
	}
}

static void
___lambda80__dc_chat_info_dialog_chat_changed (DcChatInfoDialog* _sender,
                                               gpointer self)
{
	__lambda80_ (self);
}

static gboolean
dc_chat_context_menu_show_info_co (DcChatContextMenuShowInfoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data11_ = g_slice_new0 (Block11Data);
	_data_->_data11_->_ref_count_ = 1;
	_data_->_data11_->self = g_object_ref (_data_->self);
	_data_->_data11_->chat_id = _data_->chat_id;
	_data_->_data11_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->self->priv->rpc;
	_data_->_tmp1_ = dc_chat_info_dialog_new (_data_->_tmp0_, _data_->_data11_->chat_id);
	g_object_ref_sink (_data_->_tmp1_);
	_data_->dialog = _data_->_tmp1_;
	g_signal_connect_object (_data_->dialog, "chat-deleted", (GCallback) ___lambda79__dc_chat_info_dialog_chat_deleted, _data_->self, 0);
	g_signal_connect_data (_data_->dialog, "chat-changed", (GCallback) ___lambda80__dc_chat_info_dialog_chat_changed, block11_data_ref (_data_->_data11_), (GClosureNotify) block11_data_unref, 0);
	_data_->_tmp2_ = _data_->self->priv->window;
	adw_dialog_present ((AdwDialog*) _data_->dialog, (GtkWidget*) _data_->_tmp2_);
	_g_object_unref0 (_data_->dialog);
	block11_data_unref (_data_->_data11_);
	_data_->_data11_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
dc_chat_context_menu_confirm_delete (DcChatContextMenu* self,
                                     gint chat_id,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	DcChatContextMenuConfirmDeleteData* _data_;
	DcChatContextMenu* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcChatContextMenuConfirmDeleteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_chat_context_menu_confirm_delete_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->chat_id = chat_id;
	dc_chat_context_menu_confirm_delete_co (_data_);
}

static void
dc_chat_context_menu_confirm_delete_finish (DcChatContextMenu* self,
                                            GAsyncResult* _res_)
{
	DcChatContextMenuConfirmDeleteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block12Data*
block12_data_ref (Block12Data* _data12_)
{
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}

static void
block12_data_unref (void * _userdata_)
{
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		DcChatContextMenu* self;
		self = _data12_->self;
		_g_object_unref0 (self);
		g_slice_free (Block12Data, _data12_);
	}
}

static void
__lambda82_ (Block12Data* _data12_)
{
	DcChatContextMenu* self;
	self = _data12_->self;
	dc_chat_context_menu_do_delete (self, _data12_->chat_id, NULL, NULL);
}

static void
___lambda82__dc_void_func (gpointer self)
{
	__lambda82_ (self);
}

static gboolean
dc_chat_context_menu_confirm_delete_co (DcChatContextMenuConfirmDeleteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data12_ = g_slice_new0 (Block12Data);
	_data_->_data12_->_ref_count_ = 1;
	_data_->_data12_->self = g_object_ref (_data_->self);
	_data_->_data12_->chat_id = _data_->chat_id;
	_data_->_data12_->_async_data_ = _data_;
	_data_->_tmp0_ = g_strdup ("this chat");
	_data_->chat_name = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->chat_store;
	_data_->_tmp2_ = dc_find_chat_entry (_data_->_tmp1_, _data_->_data12_->chat_id);
	_data_->entry = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->entry;
	if (_data_->_tmp3_ != NULL) {
		_data_->_tmp4_ = _data_->entry;
		_data_->_tmp5_ = dc_chat_entry_get_name (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = g_strdup (_data_->_tmp6_);
		_g_free0 (_data_->chat_name);
		_data_->chat_name = _data_->_tmp7_;
	}
	_data_->_tmp8_ = _data_->self->priv->window;
	_data_->_tmp9_ = _data_->chat_name;
	_data_->_tmp10_ = g_strdup_printf ("Remove \"%s\" from your chat list? You may still receive messages if y" \
"ou are a member.", _data_->_tmp9_);
	_data_->_tmp11_ = _data_->_tmp10_;
	dc_confirm_delete_options ((GtkWidget*) _data_->_tmp8_, "Delete Chat?", _data_->_tmp11_, ___lambda82__dc_void_func, block12_data_ref (_data_->_data12_), block12_data_unref, NULL, NULL, NULL);
	_g_free0 (_data_->_tmp11_);
	_g_object_unref0 (_data_->entry);
	_g_free0 (_data_->chat_name);
	block12_data_unref (_data_->_data12_);
	_data_->_data12_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
dc_chat_context_menu_do_delete (DcChatContextMenu* self,
                                gint chat_id,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	DcChatContextMenuDoDeleteData* _data_;
	DcChatContextMenu* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcChatContextMenuDoDeleteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_chat_context_menu_do_delete_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->chat_id = chat_id;
	dc_chat_context_menu_do_delete_co (_data_);
}

static void
dc_chat_context_menu_do_delete_finish (DcChatContextMenu* self,
                                       GAsyncResult* _res_)
{
	DcChatContextMenuDoDeleteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_chat_context_menu_do_delete_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	DcChatContextMenuDoDeleteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_chat_context_menu_do_delete_co (_data_);
}

static gboolean
dc_chat_context_menu_do_delete_co (DcChatContextMenuDoDeleteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_delete_chat (_data_->_tmp0_, _data_->chat_id, dc_chat_context_menu_do_delete_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_delete_chat_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp1_ = _data_->self->priv->window;
		dc_window_show_toast (_data_->_tmp1_, "Chat deleted");
		_data_->_tmp2_ = _data_->self->priv->window;
		_data_->_tmp3_ = dc_window_get_current_chat_id (_data_->_tmp2_);
		_data_->_tmp4_ = _data_->_tmp3_;
		if (_data_->_tmp4_ == _data_->chat_id) {
			_data_->_tmp5_ = _data_->self->priv->window;
			dc_window_clear_chat_view (_data_->_tmp5_);
		}
		_data_->_tmp6_ = _data_->self->priv->window;
		_data_->_state_ = 2;
		dc_window_load_chats (_data_->_tmp6_, dc_chat_context_menu_do_delete_ready, _data_);
		return FALSE;
		_state_2:
		dc_window_load_chats_finish (_data_->_tmp6_, _data_->_res_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp7_ = _data_->self->priv->window;
		_data_->_tmp8_ = _data_->e;
		_data_->_tmp9_ = _data_->_tmp8_->message;
		_data_->_tmp10_ = g_strconcat ("Delete failed: ", _data_->_tmp9_, NULL);
		_data_->_tmp11_ = _data_->_tmp10_;
		dc_window_show_toast (_data_->_tmp7_, _data_->_tmp11_);
		_g_free0 (_data_->_tmp11_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dc_chat_context_menu_class_init (DcChatContextMenuClass * klass,
                                 gpointer klass_data)
{
	dc_chat_context_menu_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcChatContextMenu_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_chat_context_menu_finalize;
}

static void
dc_chat_context_menu_instance_init (DcChatContextMenu * self,
                                    gpointer klass)
{
	self->priv = dc_chat_context_menu_get_instance_private (self);
}

static void
dc_chat_context_menu_finalize (GObject * obj)
{
	DcChatContextMenu * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_CHAT_CONTEXT_MENU, DcChatContextMenu);
	G_OBJECT_CLASS (dc_chat_context_menu_parent_class)->finalize (obj);
}

static GType
dc_chat_context_menu_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcChatContextMenuClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_chat_context_menu_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcChatContextMenu), 0, (GInstanceInitFunc) dc_chat_context_menu_instance_init, NULL };
	GType dc_chat_context_menu_type_id;
	dc_chat_context_menu_type_id = g_type_register_static (G_TYPE_OBJECT, "DcChatContextMenu", &g_define_type_info, 0);
	DcChatContextMenu_private_offset = g_type_add_instance_private (dc_chat_context_menu_type_id, sizeof (DcChatContextMenuPrivate));
	return dc_chat_context_menu_type_id;
}

GType
dc_chat_context_menu_get_type (void)
{
	static volatile gsize dc_chat_context_menu_type_id__once = 0;
	if (g_once_init_enter (&dc_chat_context_menu_type_id__once)) {
		GType dc_chat_context_menu_type_id;
		dc_chat_context_menu_type_id = dc_chat_context_menu_get_type_once ();
		g_once_init_leave (&dc_chat_context_menu_type_id__once, dc_chat_context_menu_type_id);
	}
	return dc_chat_context_menu_type_id__once;
}

