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

#include <adwaita.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.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_NEW_GROUP_DIALOG (dc_new_group_dialog_get_type ())
#define DC_NEW_GROUP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_NEW_GROUP_DIALOG, DcNewGroupDialog))
#define DC_NEW_GROUP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_NEW_GROUP_DIALOG, DcNewGroupDialogClass))
#define DC_IS_NEW_GROUP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_NEW_GROUP_DIALOG))
#define DC_IS_NEW_GROUP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_NEW_GROUP_DIALOG))
#define DC_NEW_GROUP_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_NEW_GROUP_DIALOG, DcNewGroupDialogClass))

typedef struct _DcNewGroupDialog DcNewGroupDialog;
typedef struct _DcNewGroupDialogClass DcNewGroupDialogClass;
typedef struct _DcNewGroupDialogPrivate DcNewGroupDialogPrivate;

#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_NEW_GROUP_DIALOG_0_PROPERTY,
	DC_NEW_GROUP_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_new_group_dialog_properties[DC_NEW_GROUP_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))

#define DC_TYPE_CONTACT_PICKER_DIALOG (dc_contact_picker_dialog_get_type ())
#define DC_CONTACT_PICKER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CONTACT_PICKER_DIALOG, DcContactPickerDialog))
#define DC_CONTACT_PICKER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CONTACT_PICKER_DIALOG, DcContactPickerDialogClass))
#define DC_IS_CONTACT_PICKER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CONTACT_PICKER_DIALOG))
#define DC_IS_CONTACT_PICKER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CONTACT_PICKER_DIALOG))
#define DC_CONTACT_PICKER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CONTACT_PICKER_DIALOG, DcContactPickerDialogClass))

typedef struct _DcContactPickerDialog DcContactPickerDialog;
typedef struct _DcContactPickerDialogClass DcContactPickerDialogClass;
typedef struct _Block67Data Block67Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DcNewGroupDialogDoCreateData DcNewGroupDialogDoCreateData;
typedef struct _DcNewGroupDialogPickAvatarData DcNewGroupDialogPickAvatarData;
enum  {
	DC_NEW_GROUP_DIALOG_GROUP_CREATED_SIGNAL,
	DC_NEW_GROUP_DIALOG_NUM_SIGNALS
};
static guint dc_new_group_dialog_signals[DC_NEW_GROUP_DIALOG_NUM_SIGNALS] = {0};

struct _DcNewGroupDialog {
	AdwDialog parent_instance;
	DcNewGroupDialogPrivate * priv;
};

struct _DcNewGroupDialogClass {
	AdwDialogClass parent_class;
};

struct _DcNewGroupDialogPrivate {
	DcRpcClient* rpc;
	gboolean is_channel;
	gchar* kind_label;
	GtkEntry* name_entry;
	GtkListBox* member_listbox;
	GPtrArray* member_emails;
	gchar* avatar_path;
	AdwAvatar* avatar_widget;
};

struct _Block67Data {
	int _ref_count_;
	DcNewGroupDialog* self;
	AdwActionRow* row;
	gchar* email;
};

struct _DcNewGroupDialogDoCreateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcNewGroupDialog* self;
	gchar* name;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	GtkEntry* _tmp7_;
	GtkEntry* _tmp8_;
	gint _tmp9_;
	DcRpcClient* _tmp10_;
	const gchar* _tmp11_;
	DcRpcClient* _tmp12_;
	const gchar* _tmp13_;
	gint new_chat_id;
	const gchar* _tmp14_;
	DcRpcClient* _tmp15_;
	const gchar* _tmp16_;
	guint i;
	gboolean _tmp17_;
	guint _tmp18_;
	GPtrArray* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	gchar* email;
	GPtrArray* _tmp22_;
	gconstpointer _tmp23_;
	gchar* _tmp24_;
	gint contact_id;
	DcRpcClient* _tmp25_;
	const gchar* _tmp26_;
	DcRpcClient* _tmp27_;
	GError* e;
	GError* _tmp28_;
	const gchar* _tmp29_;
	GError* _inner_error0_;
};

struct _DcNewGroupDialogPickAvatarData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcNewGroupDialog* self;
	gchar* path;
	GtkRoot* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	AdwAvatar* _tmp11_;
	const gchar* _tmp12_;
	GdkTexture* _tmp13_;
	GdkTexture* _tmp14_;
};

static gint DcNewGroupDialog_private_offset;
static gpointer dc_new_group_dialog_parent_class = NULL;

VALA_EXTERN GType dc_new_group_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcNewGroupDialog, g_object_unref)
VALA_EXTERN GType dc_rpc_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRpcClient, g_object_unref)
static void _g_free0_ (gpointer var);
VALA_EXTERN DcNewGroupDialog* dc_new_group_dialog_new (DcRpcClient* rpc,
                                           gboolean is_channel);
VALA_EXTERN DcNewGroupDialog* dc_new_group_dialog_construct (GType object_type,
                                                 DcRpcClient* rpc,
                                                 gboolean is_channel);
static void __lambda272_ (DcNewGroupDialog* self);
static void dc_new_group_dialog_do_create (DcNewGroupDialog* self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
static void dc_new_group_dialog_do_create_finish (DcNewGroupDialog* self,
                                           GAsyncResult* _res_);
static void ___lambda272__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda273_ (DcNewGroupDialog* self);
static void dc_new_group_dialog_pick_avatar (DcNewGroupDialog* self,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);
static void dc_new_group_dialog_pick_avatar_finish (DcNewGroupDialog* self,
                                             GAsyncResult* _res_);
static void ___lambda273__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda274_ (DcNewGroupDialog* self);
static void ___lambda274__gtk_editable_changed (GtkEditable* _sender,
                                         gpointer self);
static void dc_new_group_dialog_on_pick_member (DcNewGroupDialog* self);
static void _dc_new_group_dialog_on_pick_member_gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self);
VALA_EXTERN GType dc_contact_picker_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcContactPickerDialog, g_object_unref)
VALA_EXTERN DcContactPickerDialog* dc_contact_picker_dialog_new (DcRpcClient* rpc,
                                                     GListStore* chat_store,
                                                     const gchar* title);
VALA_EXTERN DcContactPickerDialog* dc_contact_picker_dialog_construct (GType object_type,
                                                           DcRpcClient* rpc,
                                                           GListStore* chat_store,
                                                           const gchar* title);
static void __lambda275_ (DcNewGroupDialog* self,
                   gint contact_id,
                   const gchar* email);
VALA_EXTERN void dc_new_group_dialog_add_member_email (DcNewGroupDialog* self,
                                           const gchar* email);
static void ___lambda275__dc_contact_picker_dialog_contact_picked (DcContactPickerDialog* _sender,
                                                            gint contact_id,
                                                            const gchar* email,
                                                            gpointer self);
static Block67Data* block67_data_ref (Block67Data* _data67_);
static void block67_data_unref (void * _userdata_);
static void __lambda276_ (Block67Data* _data67_);
static void ___lambda276__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_new_group_dialog_do_create_data_free (gpointer _data);
static gboolean dc_new_group_dialog_do_create_co (DcNewGroupDialogDoCreateData* _data_);
VALA_EXTERN void dc_rpc_client_create_broadcast (DcRpcClient* self,
                                     const gchar* name,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN gint dc_rpc_client_create_broadcast_finish (DcRpcClient* self,
                                            GAsyncResult* _res_,
                                            GError** error);
static void dc_new_group_dialog_do_create_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_create_group (DcRpcClient* self,
                                 const gchar* name,
                                 gboolean protect,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_);
VALA_EXTERN gint dc_rpc_client_create_group_finish (DcRpcClient* self,
                                        GAsyncResult* _res_,
                                        GError** error);
VALA_EXTERN void dc_rpc_client_set_chat_profile_image (DcRpcClient* self,
                                           gint chat_id,
                                           const gchar* image_path,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_set_chat_profile_image_finish (DcRpcClient* self,
                                                  GAsyncResult* _res_,
                                                  GError** error);
VALA_EXTERN void dc_rpc_client_get_or_create_contact (DcRpcClient* self,
                                          const gchar* email,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN gint dc_rpc_client_get_or_create_contact_finish (DcRpcClient* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
VALA_EXTERN void dc_rpc_client_add_contact_to_chat (DcRpcClient* self,
                                        gint chat_id,
                                        gint contact_id,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_add_contact_to_chat_finish (DcRpcClient* self,
                                               GAsyncResult* _res_,
                                               GError** error);
VALA_EXTERN void dc_show_error (GtkWidget* parent,
                    const gchar* message);
static void dc_new_group_dialog_pick_avatar_data_free (gpointer _data);
static gboolean dc_new_group_dialog_pick_avatar_co (DcNewGroupDialogPickAvatarData* _data_);
VALA_EXTERN void dc_pick_image_file (GtkWindow* parent,
                         const gchar* title,
                         GAsyncReadyCallback _callback_,
                         gpointer _user_data_);
VALA_EXTERN gchar* dc_pick_image_file_finish (GAsyncResult* _res_);
static void dc_new_group_dialog_pick_avatar_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_);
VALA_EXTERN GdkTexture* dc_load_avatar (const gchar* path);
static void dc_new_group_dialog_finalize (GObject * obj);
static GType dc_new_group_dialog_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dc_new_group_dialog_get_instance_private (DcNewGroupDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcNewGroupDialog_private_offset);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

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

static void
__lambda272_ (DcNewGroupDialog* self)
{
	dc_new_group_dialog_do_create (self, NULL, NULL);
}

static void
___lambda272__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda272_ ((DcNewGroupDialog*) self);
}

static void
__lambda273_ (DcNewGroupDialog* self)
{
	dc_new_group_dialog_pick_avatar (self, NULL, NULL);
}

static void
___lambda273__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda273_ ((DcNewGroupDialog*) self);
}

static void
__lambda274_ (DcNewGroupDialog* self)
{
	const gchar* _tmp0_ = NULL;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	AdwAvatar* _tmp10_;
	_tmp1_ = self->priv->name_entry;
	_tmp2_ = gtk_editable_get_text ((GtkEditable*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ > 0) {
		GtkEntry* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp6_ = self->priv->name_entry;
		_tmp7_ = gtk_editable_get_text ((GtkEditable*) _tmp6_);
		_tmp8_ = _tmp7_;
		_tmp0_ = _tmp8_;
	} else {
		const gchar* _tmp9_;
		_tmp9_ = self->priv->kind_label;
		_tmp0_ = _tmp9_;
	}
	_tmp10_ = self->priv->avatar_widget;
	adw_avatar_set_text (_tmp10_, _tmp0_);
}

static void
___lambda274__gtk_editable_changed (GtkEditable* _sender,
                                    gpointer self)
{
	__lambda274_ ((DcNewGroupDialog*) self);
}

static void
_dc_new_group_dialog_on_pick_member_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self)
{
	dc_new_group_dialog_on_pick_member ((DcNewGroupDialog*) self);
}

DcNewGroupDialog*
dc_new_group_dialog_construct (GType object_type,
                               DcRpcClient* rpc,
                               gboolean is_channel)
{
	DcNewGroupDialog * self = NULL;
	DcRpcClient* _tmp0_;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	const gchar* _tmp3_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp4_;
	AdwHeaderBar* header = NULL;
	AdwHeaderBar* _tmp5_;
	GtkButton* create_btn = NULL;
	GtkButton* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	AdwHeaderBar* _tmp9_;
	GtkButton* _tmp10_;
	GtkBox* _tmp11_;
	AdwHeaderBar* _tmp12_;
	GtkBox* content = NULL;
	GtkBox* _tmp13_;
	GtkBox* _tmp14_;
	GtkBox* _tmp15_;
	GtkBox* _tmp16_;
	GtkBox* _tmp17_;
	const gchar* _tmp18_;
	AdwAvatar* _tmp19_;
	AdwAvatar* _tmp20_;
	GtkBox* _tmp21_;
	AdwAvatar* _tmp22_;
	GtkButton* avatar_btn = NULL;
	GtkButton* _tmp23_;
	GtkButton* _tmp24_;
	GtkButton* _tmp25_;
	GtkButton* _tmp26_;
	GtkBox* _tmp27_;
	GtkButton* _tmp28_;
	GtkLabel* name_lbl = NULL;
	const gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	GtkLabel* _tmp32_;
	GtkLabel* _tmp33_;
	GtkLabel* _tmp34_;
	GtkLabel* _tmp35_;
	GtkBox* _tmp36_;
	GtkLabel* _tmp37_;
	GtkEntry* _tmp38_;
	GtkEntry* _tmp39_;
	const gchar* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	GtkEntry* _tmp43_;
	GtkBox* _tmp44_;
	GtkEntry* _tmp45_;
	GtkBox* _tmp53_;
	GtkSeparator* _tmp54_;
	GtkSeparator* _tmp55_;
	GtkBox* members_header = NULL;
	GtkBox* _tmp56_;
	GtkLabel* members_lbl = NULL;
	GtkLabel* _tmp57_;
	GtkBox* _tmp58_;
	GtkButton* add_btn = NULL;
	GtkButton* _tmp59_;
	GtkBox* _tmp60_;
	GtkListBox* _tmp61_;
	GtkListBox* _tmp62_;
	GtkListBox* _tmp63_;
	GtkBox* _tmp64_;
	GtkListBox* _tmp65_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp66_;
	GtkBox* _tmp67_;
	GtkBox* _tmp68_;
	GtkBox* _tmp69_;
	g_return_val_if_fail (rpc != NULL, NULL);
	self = (DcNewGroupDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (self->priv->rpc);
	self->priv->rpc = _tmp0_;
	self->priv->is_channel = is_channel;
	if (is_channel) {
		_tmp1_ = "Channel";
	} else {
		_tmp1_ = "Group";
	}
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (self->priv->kind_label);
	self->priv->kind_label = _tmp2_;
	if (is_channel) {
		_tmp3_ = "New Channel";
	} else {
		_tmp3_ = "New Group";
	}
	adw_dialog_set_title ((AdwDialog*) self, _tmp3_);
	adw_dialog_set_content_width ((AdwDialog*) self, 360);
	adw_dialog_set_content_height ((AdwDialog*) self, 480);
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp4_);
	box = _tmp4_;
	_tmp5_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp5_);
	header = _tmp5_;
	_tmp6_ = (GtkButton*) gtk_button_new_with_label ("Create");
	g_object_ref_sink (_tmp6_);
	create_btn = _tmp6_;
	_tmp7_ = create_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp7_, "suggested-action");
	_tmp8_ = create_btn;
	g_signal_connect_object (_tmp8_, "clicked", (GCallback) ___lambda272__gtk_button_clicked, self, 0);
	_tmp9_ = header;
	_tmp10_ = create_btn;
	adw_header_bar_pack_end (_tmp9_, (GtkWidget*) _tmp10_);
	_tmp11_ = box;
	_tmp12_ = header;
	gtk_box_append (_tmp11_, (GtkWidget*) _tmp12_);
	_tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp13_);
	content = _tmp13_;
	_tmp14_ = content;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp14_, 16);
	_tmp15_ = content;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp15_, 16);
	_tmp16_ = content;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp16_, 12);
	_tmp17_ = content;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp17_, 16);
	_tmp18_ = self->priv->kind_label;
	_tmp19_ = (AdwAvatar*) adw_avatar_new (72, _tmp18_, TRUE);
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->avatar_widget);
	self->priv->avatar_widget = _tmp19_;
	_tmp20_ = self->priv->avatar_widget;
	gtk_widget_set_halign ((GtkWidget*) _tmp20_, GTK_ALIGN_CENTER);
	_tmp21_ = content;
	_tmp22_ = self->priv->avatar_widget;
	gtk_box_append (_tmp21_, (GtkWidget*) _tmp22_);
	_tmp23_ = (GtkButton*) gtk_button_new_with_label ("Set Avatar");
	g_object_ref_sink (_tmp23_);
	avatar_btn = _tmp23_;
	_tmp24_ = avatar_btn;
	gtk_widget_set_halign ((GtkWidget*) _tmp24_, GTK_ALIGN_CENTER);
	_tmp25_ = avatar_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp25_, "flat");
	_tmp26_ = avatar_btn;
	g_signal_connect_object (_tmp26_, "clicked", (GCallback) ___lambda273__gtk_button_clicked, self, 0);
	_tmp27_ = content;
	_tmp28_ = avatar_btn;
	gtk_box_append (_tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = self->priv->kind_label;
	_tmp30_ = g_strconcat (_tmp29_, " Name", NULL);
	_tmp31_ = _tmp30_;
	_tmp32_ = (GtkLabel*) gtk_label_new (_tmp31_);
	g_object_ref_sink (_tmp32_);
	_tmp33_ = _tmp32_;
	_g_free0 (_tmp31_);
	name_lbl = _tmp33_;
	_tmp34_ = name_lbl;
	gtk_widget_add_css_class ((GtkWidget*) _tmp34_, "heading");
	_tmp35_ = name_lbl;
	gtk_widget_set_halign ((GtkWidget*) _tmp35_, GTK_ALIGN_START);
	_tmp36_ = content;
	_tmp37_ = name_lbl;
	gtk_box_append (_tmp36_, (GtkWidget*) _tmp37_);
	_tmp38_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp38_);
	_g_object_unref0 (self->priv->name_entry);
	self->priv->name_entry = _tmp38_;
	_tmp39_ = self->priv->name_entry;
	_tmp40_ = self->priv->kind_label;
	_tmp41_ = g_strconcat ("My ", _tmp40_, NULL);
	_tmp42_ = _tmp41_;
	gtk_entry_set_placeholder_text (_tmp39_, _tmp42_);
	_g_free0 (_tmp42_);
	_tmp43_ = self->priv->name_entry;
	g_signal_connect_object ((GtkEditable*) _tmp43_, "changed", (GCallback) ___lambda274__gtk_editable_changed, self, 0);
	_tmp44_ = content;
	_tmp45_ = self->priv->name_entry;
	gtk_box_append (_tmp44_, (GtkWidget*) _tmp45_);
	if (is_channel) {
		GtkLabel* hint = NULL;
		GtkLabel* _tmp46_;
		GtkLabel* _tmp47_;
		GtkLabel* _tmp48_;
		GtkLabel* _tmp49_;
		GtkLabel* _tmp50_;
		GtkBox* _tmp51_;
		GtkLabel* _tmp52_;
		_tmp46_ = (GtkLabel*) gtk_label_new ("Only you can write in a channel. Members read messages without seeing " \
"each other.");
		g_object_ref_sink (_tmp46_);
		hint = _tmp46_;
		_tmp47_ = hint;
		gtk_label_set_wrap (_tmp47_, TRUE);
		_tmp48_ = hint;
		gtk_label_set_xalign (_tmp48_, (gfloat) 0);
		_tmp49_ = hint;
		gtk_widget_add_css_class ((GtkWidget*) _tmp49_, "dim-label");
		_tmp50_ = hint;
		gtk_widget_add_css_class ((GtkWidget*) _tmp50_, "caption");
		_tmp51_ = content;
		_tmp52_ = hint;
		gtk_box_append (_tmp51_, (GtkWidget*) _tmp52_);
		_g_object_unref0 (hint);
	}
	_tmp53_ = content;
	_tmp54_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp54_);
	_tmp55_ = _tmp54_;
	gtk_box_append (_tmp53_, (GtkWidget*) _tmp55_);
	_g_object_unref0 (_tmp55_);
	_tmp56_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp56_);
	members_header = _tmp56_;
	_tmp57_ = (GtkLabel*) gtk_label_new ("Members");
	g_object_ref_sink (_tmp57_);
	members_lbl = _tmp57_;
	gtk_widget_add_css_class ((GtkWidget*) members_lbl, "heading");
	gtk_widget_set_halign ((GtkWidget*) members_lbl, GTK_ALIGN_START);
	gtk_widget_set_hexpand ((GtkWidget*) members_lbl, TRUE);
	gtk_box_append (members_header, (GtkWidget*) members_lbl);
	_tmp58_ = content;
	gtk_box_append (_tmp58_, (GtkWidget*) members_header);
	_tmp59_ = (GtkButton*) gtk_button_new_with_label ("Add Member\u2026");
	g_object_ref_sink (_tmp59_);
	add_btn = _tmp59_;
	gtk_widget_add_css_class ((GtkWidget*) add_btn, "suggested-action");
	g_signal_connect_object (add_btn, "clicked", (GCallback) _dc_new_group_dialog_on_pick_member_gtk_button_clicked, self, 0);
	_tmp60_ = content;
	gtk_box_append (_tmp60_, (GtkWidget*) add_btn);
	_tmp61_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp61_);
	_g_object_unref0 (self->priv->member_listbox);
	self->priv->member_listbox = _tmp61_;
	_tmp62_ = self->priv->member_listbox;
	gtk_list_box_set_selection_mode (_tmp62_, GTK_SELECTION_NONE);
	_tmp63_ = self->priv->member_listbox;
	gtk_widget_add_css_class ((GtkWidget*) _tmp63_, "boxed-list");
	_tmp64_ = content;
	_tmp65_ = self->priv->member_listbox;
	gtk_box_append (_tmp64_, (GtkWidget*) _tmp65_);
	_tmp66_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp66_);
	scroll = _tmp66_;
	gtk_widget_set_vexpand ((GtkWidget*) scroll, TRUE);
	g_object_set (scroll, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp67_ = content;
	gtk_scrolled_window_set_child (scroll, (GtkWidget*) _tmp67_);
	_tmp68_ = box;
	gtk_box_append (_tmp68_, (GtkWidget*) scroll);
	_tmp69_ = box;
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) _tmp69_);
	_g_object_unref0 (scroll);
	_g_object_unref0 (add_btn);
	_g_object_unref0 (members_lbl);
	_g_object_unref0 (members_header);
	_g_object_unref0 (name_lbl);
	_g_object_unref0 (avatar_btn);
	_g_object_unref0 (content);
	_g_object_unref0 (create_btn);
	_g_object_unref0 (header);
	_g_object_unref0 (box);
	return self;
}

DcNewGroupDialog*
dc_new_group_dialog_new (DcRpcClient* rpc,
                         gboolean is_channel)
{
	return dc_new_group_dialog_construct (DC_TYPE_NEW_GROUP_DIALOG, rpc, is_channel);
}

static void
__lambda275_ (DcNewGroupDialog* self,
              gint contact_id,
              const gchar* email)
{
	g_return_if_fail (email != NULL);
	dc_new_group_dialog_add_member_email (self, email);
}

static void
___lambda275__dc_contact_picker_dialog_contact_picked (DcContactPickerDialog* _sender,
                                                       gint contact_id,
                                                       const gchar* email,
                                                       gpointer self)
{
	__lambda275_ ((DcNewGroupDialog*) self, contact_id, email);
}

static void
dc_new_group_dialog_on_pick_member (DcNewGroupDialog* self)
{
	DcContactPickerDialog* picker = NULL;
	DcRpcClient* _tmp0_;
	DcContactPickerDialog* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->rpc;
	_tmp1_ = dc_contact_picker_dialog_new (_tmp0_, NULL, NULL);
	g_object_ref_sink (_tmp1_);
	picker = _tmp1_;
	g_signal_connect_object (picker, "contact-picked", (GCallback) ___lambda275__dc_contact_picker_dialog_contact_picked, self, 0);
	adw_dialog_present ((AdwDialog*) picker, (GtkWidget*) self);
	_g_object_unref0 (picker);
}

static Block67Data*
block67_data_ref (Block67Data* _data67_)
{
	g_atomic_int_inc (&_data67_->_ref_count_);
	return _data67_;
}

static void
block67_data_unref (void * _userdata_)
{
	Block67Data* _data67_;
	_data67_ = (Block67Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data67_->_ref_count_)) {
		DcNewGroupDialog* self;
		self = _data67_->self;
		_g_object_unref0 (_data67_->row);
		_g_free0 (_data67_->email);
		_g_object_unref0 (self);
		g_slice_free (Block67Data, _data67_);
	}
}

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 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
__lambda276_ (Block67Data* _data67_)
{
	DcNewGroupDialog* self;
	GtkListBox* _tmp8_;
	AdwActionRow* _tmp9_;
	self = _data67_->self;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp2_;
				gint _tmp3_;
				gint _tmp4_;
				GPtrArray* _tmp5_;
				gconstpointer _tmp6_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->member_emails;
				_tmp3_ = vala_g_ptr_array_get_length (_tmp2_);
				_tmp4_ = _tmp3_;
				if (!(i < ((guint) _tmp4_))) {
					break;
				}
				_tmp5_ = self->priv->member_emails;
				_tmp6_ = g_ptr_array_index (_tmp5_, i);
				if (g_strcmp0 ((const gchar*) _tmp6_, _data67_->email) == 0) {
					GPtrArray* _tmp7_;
					_tmp7_ = self->priv->member_emails;
					g_ptr_array_remove_index (_tmp7_, i);
					break;
				}
			}
		}
	}
	_tmp8_ = self->priv->member_listbox;
	_tmp9_ = _data67_->row;
	gtk_list_box_remove (_tmp8_, (GtkWidget*) _tmp9_);
}

static void
___lambda276__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda276_ (self);
}

void
dc_new_group_dialog_add_member_email (DcNewGroupDialog* self,
                                      const gchar* email)
{
	Block67Data* _data67_;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gint _tmp2_;
	gint _tmp3_;
	GPtrArray* _tmp11_;
	gchar* _tmp12_;
	AdwActionRow* _tmp13_;
	AdwActionRow* _tmp14_;
	AdwAvatar* avatar = NULL;
	AdwAvatar* _tmp15_;
	AdwActionRow* _tmp16_;
	AdwAvatar* _tmp17_;
	GtkButton* remove_btn = NULL;
	GtkButton* _tmp18_;
	GtkButton* _tmp19_;
	GtkButton* _tmp20_;
	GtkButton* _tmp21_;
	GtkButton* _tmp22_;
	AdwActionRow* _tmp23_;
	GtkButton* _tmp24_;
	GtkListBox* _tmp25_;
	AdwActionRow* _tmp26_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (email != NULL);
	_data67_ = g_slice_new0 (Block67Data);
	_data67_->_ref_count_ = 1;
	_data67_->self = g_object_ref (self);
	_tmp0_ = g_strdup (email);
	_g_free0 (_data67_->email);
	_data67_->email = _tmp0_;
	_tmp2_ = strlen (_data67_->email);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == 0) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = !string_contains (_data67_->email, "@");
	}
	if (_tmp1_) {
		block67_data_unref (_data67_);
		_data67_ = NULL;
		return;
	}
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp6_;
				gint _tmp7_;
				gint _tmp8_;
				GPtrArray* _tmp9_;
				gconstpointer _tmp10_;
				if (!_tmp4_) {
					guint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp6_ = self->priv->member_emails;
				_tmp7_ = vala_g_ptr_array_get_length (_tmp6_);
				_tmp8_ = _tmp7_;
				if (!(i < ((guint) _tmp8_))) {
					break;
				}
				_tmp9_ = self->priv->member_emails;
				_tmp10_ = g_ptr_array_index (_tmp9_, i);
				if (g_strcmp0 ((const gchar*) _tmp10_, _data67_->email) == 0) {
					block67_data_unref (_data67_);
					_data67_ = NULL;
					return;
				}
			}
		}
	}
	_tmp11_ = self->priv->member_emails;
	_tmp12_ = g_strdup (_data67_->email);
	g_ptr_array_add (_tmp11_, _tmp12_);
	_tmp13_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp13_);
	_data67_->row = _tmp13_;
	_tmp14_ = _data67_->row;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp14_, _data67_->email);
	_tmp15_ = (AdwAvatar*) adw_avatar_new (28, _data67_->email, TRUE);
	g_object_ref_sink (_tmp15_);
	avatar = _tmp15_;
	_tmp16_ = _data67_->row;
	_tmp17_ = avatar;
	adw_action_row_add_prefix (_tmp16_, (GtkWidget*) _tmp17_);
	_tmp18_ = (GtkButton*) gtk_button_new_from_icon_name ("user-trash-symbolic");
	g_object_ref_sink (_tmp18_);
	remove_btn = _tmp18_;
	_tmp19_ = remove_btn;
	gtk_widget_set_valign ((GtkWidget*) _tmp19_, GTK_ALIGN_CENTER);
	_tmp20_ = remove_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp20_, "flat");
	_tmp21_ = remove_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp21_, "error");
	_tmp22_ = remove_btn;
	g_signal_connect_data (_tmp22_, "clicked", (GCallback) ___lambda276__gtk_button_clicked, block67_data_ref (_data67_), (GClosureNotify) block67_data_unref, 0);
	_tmp23_ = _data67_->row;
	_tmp24_ = remove_btn;
	adw_action_row_add_suffix (_tmp23_, (GtkWidget*) _tmp24_);
	_tmp25_ = self->priv->member_listbox;
	_tmp26_ = _data67_->row;
	gtk_list_box_append (_tmp25_, (GtkWidget*) _tmp26_);
	_g_object_unref0 (remove_btn);
	_g_object_unref0 (avatar);
	block67_data_unref (_data67_);
	_data67_ = NULL;
}

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

static void
dc_new_group_dialog_do_create (DcNewGroupDialog* self,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	DcNewGroupDialogDoCreateData* _data_;
	DcNewGroupDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcNewGroupDialogDoCreateData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_new_group_dialog_do_create_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_new_group_dialog_do_create_co (_data_);
}

static void
dc_new_group_dialog_do_create_finish (DcNewGroupDialog* self,
                                      GAsyncResult* _res_)
{
	DcNewGroupDialogDoCreateData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

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

static void
dc_new_group_dialog_do_create_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	DcNewGroupDialogDoCreateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_new_group_dialog_do_create_co (_data_);
}

static gboolean
dc_new_group_dialog_do_create_co (DcNewGroupDialogDoCreateData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		case 5:
		goto _state_5;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->name_entry;
	_data_->_tmp1_ = gtk_editable_get_text ((GtkEditable*) _data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = string_strip (_data_->_tmp2_);
	_data_->name = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->name;
	_data_->_tmp5_ = strlen (_data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	if (_data_->_tmp6_ == 0) {
		_data_->_tmp7_ = _data_->self->priv->name_entry;
		gtk_widget_add_css_class ((GtkWidget*) _data_->_tmp7_, "error");
		_g_free0 (_data_->name);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp8_ = _data_->self->priv->name_entry;
	gtk_widget_remove_css_class ((GtkWidget*) _data_->_tmp8_, "error");
	{
		if (_data_->self->priv->is_channel) {
			_data_->_tmp10_ = _data_->self->priv->rpc;
			_data_->_tmp11_ = _data_->name;
			_data_->_state_ = 1;
			dc_rpc_client_create_broadcast (_data_->_tmp10_, _data_->_tmp11_, dc_new_group_dialog_do_create_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp9_ = dc_rpc_client_create_broadcast_finish (_data_->_tmp10_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		} else {
			_data_->_tmp12_ = _data_->self->priv->rpc;
			_data_->_tmp13_ = _data_->name;
			_data_->_state_ = 2;
			dc_rpc_client_create_group (_data_->_tmp12_, _data_->_tmp13_, TRUE, dc_new_group_dialog_do_create_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp9_ = dc_rpc_client_create_group_finish (_data_->_tmp12_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		_data_->new_chat_id = _data_->_tmp9_;
		_data_->_tmp14_ = _data_->self->priv->avatar_path;
		if (_data_->_tmp14_ != NULL) {
			{
				_data_->_tmp15_ = _data_->self->priv->rpc;
				_data_->_tmp16_ = _data_->self->priv->avatar_path;
				_data_->_state_ = 3;
				dc_rpc_client_set_chat_profile_image (_data_->_tmp15_, _data_->new_chat_id, _data_->_tmp16_, dc_new_group_dialog_do_create_ready, _data_);
				return FALSE;
				_state_3:
				dc_rpc_client_set_chat_profile_image_finish (_data_->_tmp15_, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch1_g_error;
				}
			}
			goto __finally1;
			__catch1_g_error:
			{
				g_clear_error (&_data_->_inner_error0_);
			}
			__finally1:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		{
			_data_->i = (guint) 0;
			{
				_data_->_tmp17_ = TRUE;
				while (TRUE) {
					if (!_data_->_tmp17_) {
						_data_->_tmp18_ = _data_->i;
						_data_->i = _data_->_tmp18_ + 1;
					}
					_data_->_tmp17_ = FALSE;
					_data_->_tmp19_ = _data_->self->priv->member_emails;
					_data_->_tmp20_ = vala_g_ptr_array_get_length (_data_->_tmp19_);
					_data_->_tmp21_ = _data_->_tmp20_;
					if (!(_data_->i < ((guint) _data_->_tmp21_))) {
						break;
					}
					_data_->_tmp22_ = _data_->self->priv->member_emails;
					_data_->_tmp23_ = g_ptr_array_index (_data_->_tmp22_, _data_->i);
					_data_->_tmp24_ = g_strdup ((const gchar*) _data_->_tmp23_);
					_data_->email = _data_->_tmp24_;
					{
						_data_->_tmp25_ = _data_->self->priv->rpc;
						_data_->_tmp26_ = _data_->email;
						_data_->_state_ = 4;
						dc_rpc_client_get_or_create_contact (_data_->_tmp25_, _data_->_tmp26_, dc_new_group_dialog_do_create_ready, _data_);
						return FALSE;
						_state_4:
						_data_->contact_id = dc_rpc_client_get_or_create_contact_finish (_data_->_tmp25_, _data_->_res_, &_data_->_inner_error0_);
						if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
							goto __catch2_g_error;
						}
						_data_->_tmp27_ = _data_->self->priv->rpc;
						_data_->_state_ = 5;
						dc_rpc_client_add_contact_to_chat (_data_->_tmp27_, _data_->new_chat_id, _data_->contact_id, dc_new_group_dialog_do_create_ready, _data_);
						return FALSE;
						_state_5:
						dc_rpc_client_add_contact_to_chat_finish (_data_->_tmp27_, _data_->_res_, &_data_->_inner_error0_);
						if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
							goto __catch2_g_error;
						}
					}
					goto __finally2;
					__catch2_g_error:
					{
						g_clear_error (&_data_->_inner_error0_);
					}
					__finally2:
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						_g_free0 (_data_->email);
						goto __catch0_g_error;
					}
					_g_free0 (_data_->email);
				}
			}
		}
		g_signal_emit (_data_->self, dc_new_group_dialog_signals[DC_NEW_GROUP_DIALOG_GROUP_CREATED_SIGNAL], 0, _data_->new_chat_id);
		adw_dialog_close ((AdwDialog*) _data_->self);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp28_ = _data_->e;
		_data_->_tmp29_ = _data_->_tmp28_->message;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp29_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->name);
		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_free0 (_data_->name);
	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_new_group_dialog_pick_avatar_data_free (gpointer _data)
{
	DcNewGroupDialogPickAvatarData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DcNewGroupDialogPickAvatarData, _data_);
}

static void
dc_new_group_dialog_pick_avatar (DcNewGroupDialog* self,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_)
{
	DcNewGroupDialogPickAvatarData* _data_;
	DcNewGroupDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcNewGroupDialogPickAvatarData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_new_group_dialog_pick_avatar_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_new_group_dialog_pick_avatar_co (_data_);
}

static void
dc_new_group_dialog_pick_avatar_finish (DcNewGroupDialog* self,
                                        GAsyncResult* _res_)
{
	DcNewGroupDialogPickAvatarData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_new_group_dialog_pick_avatar_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_)
{
	DcNewGroupDialogPickAvatarData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_new_group_dialog_pick_avatar_co (_data_);
}

static gboolean
dc_new_group_dialog_pick_avatar_co (DcNewGroupDialogPickAvatarData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gtk_widget_get_root ((GtkWidget*) _data_->self);
	_data_->_tmp1_ = _data_->self->priv->kind_label;
	_data_->_tmp2_ = g_strconcat ("Select ", _data_->_tmp1_, NULL);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = g_strconcat (_data_->_tmp3_, " Avatar", NULL);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_state_ = 1;
	dc_pick_image_file (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, gtk_window_get_type (), GtkWindow), _data_->_tmp5_, dc_new_group_dialog_pick_avatar_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp6_ = dc_pick_image_file_finish (_data_->_res_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_g_free0 (_data_->_tmp5_);
	_g_free0 (_data_->_tmp3_);
	_data_->path = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->path;
	if (_data_->_tmp8_ != NULL) {
		_data_->_tmp9_ = _data_->path;
		_data_->_tmp10_ = g_strdup (_data_->_tmp9_);
		_g_free0 (_data_->self->priv->avatar_path);
		_data_->self->priv->avatar_path = _data_->_tmp10_;
		_data_->_tmp11_ = _data_->self->priv->avatar_widget;
		_data_->_tmp12_ = _data_->path;
		_data_->_tmp13_ = dc_load_avatar (_data_->_tmp12_);
		_data_->_tmp14_ = _data_->_tmp13_;
		adw_avatar_set_custom_image (_data_->_tmp11_, (GdkPaintable*) _data_->_tmp14_);
		_g_object_unref0 (_data_->_tmp14_);
	}
	_g_free0 (_data_->path);
	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_new_group_dialog_class_init (DcNewGroupDialogClass * klass,
                                gpointer klass_data)
{
	dc_new_group_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcNewGroupDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_new_group_dialog_finalize;
	dc_new_group_dialog_signals[DC_NEW_GROUP_DIALOG_GROUP_CREATED_SIGNAL] = g_signal_new ("group-created", DC_TYPE_NEW_GROUP_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
}

static void
dc_new_group_dialog_instance_init (DcNewGroupDialog * self,
                                   gpointer klass)
{
	GPtrArray* _tmp0_;
	self->priv = dc_new_group_dialog_get_instance_private (self);
	_tmp0_ = g_ptr_array_new_full ((guint) 0, _g_free0_);
	self->priv->member_emails = _tmp0_;
	self->priv->avatar_path = NULL;
}

static void
dc_new_group_dialog_finalize (GObject * obj)
{
	DcNewGroupDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_NEW_GROUP_DIALOG, DcNewGroupDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_free0 (self->priv->kind_label);
	_g_object_unref0 (self->priv->name_entry);
	_g_object_unref0 (self->priv->member_listbox);
	_g_ptr_array_unref0 (self->priv->member_emails);
	_g_free0 (self->priv->avatar_path);
	_g_object_unref0 (self->priv->avatar_widget);
	G_OBJECT_CLASS (dc_new_group_dialog_parent_class)->finalize (obj);
}

static GType
dc_new_group_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcNewGroupDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_new_group_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcNewGroupDialog), 0, (GInstanceInitFunc) dc_new_group_dialog_instance_init, NULL };
	GType dc_new_group_dialog_type_id;
	dc_new_group_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcNewGroupDialog", &g_define_type_info, 0);
	DcNewGroupDialog_private_offset = g_type_add_instance_private (dc_new_group_dialog_type_id, sizeof (DcNewGroupDialogPrivate));
	return dc_new_group_dialog_type_id;
}

GType
dc_new_group_dialog_get_type (void)
{
	static volatile gsize dc_new_group_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_new_group_dialog_type_id__once)) {
		GType dc_new_group_dialog_type_id;
		dc_new_group_dialog_type_id = dc_new_group_dialog_get_type_once ();
		g_once_init_leave (&dc_new_group_dialog_type_id__once, dc_new_group_dialog_type_id);
	}
	return dc_new_group_dialog_type_id__once;
}

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

