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

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

#define DC_STICKER_MANAGER_DIALOG_THUMB_SIZE 96
#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_STICKER_MANAGER_DIALOG (dc_sticker_manager_dialog_get_type ())
#define DC_STICKER_MANAGER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_STICKER_MANAGER_DIALOG, DcStickerManagerDialog))
#define DC_STICKER_MANAGER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_STICKER_MANAGER_DIALOG, DcStickerManagerDialogClass))
#define DC_IS_STICKER_MANAGER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_STICKER_MANAGER_DIALOG))
#define DC_IS_STICKER_MANAGER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_STICKER_MANAGER_DIALOG))
#define DC_STICKER_MANAGER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_STICKER_MANAGER_DIALOG, DcStickerManagerDialogClass))

typedef struct _DcStickerManagerDialog DcStickerManagerDialog;
typedef struct _DcStickerManagerDialogClass DcStickerManagerDialogClass;
typedef struct _DcStickerManagerDialogPrivate DcStickerManagerDialogPrivate;

#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;
enum  {
	DC_STICKER_MANAGER_DIALOG_0_PROPERTY,
	DC_STICKER_MANAGER_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_sticker_manager_dialog_properties[DC_STICKER_MANAGER_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))
typedef struct _DcStickerManagerDialogPromptNewPackData DcStickerManagerDialogPromptNewPackData;
typedef struct _Block58Data Block58Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define DC_TYPE_STICKER (dc_sticker_get_type ())
#define DC_STICKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_STICKER, DcSticker))
#define DC_STICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_STICKER, DcStickerClass))
#define DC_IS_STICKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_STICKER))
#define DC_IS_STICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_STICKER))
#define DC_STICKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_STICKER, DcStickerClass))

typedef struct _DcSticker DcSticker;
typedef struct _DcStickerClass DcStickerClass;
typedef struct _Block59Data Block59Data;
typedef struct _DcStickerPrivate DcStickerPrivate;
typedef struct _Block60Data Block60Data;
typedef struct _Block61Data Block61Data;

#define DC_TYPE_POPOVER_BUTTON (dc_popover_button_get_type ())
#define DC_POPOVER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_POPOVER_BUTTON, DcPopoverButton))
#define DC_POPOVER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_POPOVER_BUTTON, DcPopoverButtonClass))
#define DC_IS_POPOVER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_POPOVER_BUTTON))
#define DC_IS_POPOVER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_POPOVER_BUTTON))
#define DC_POPOVER_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_POPOVER_BUTTON, DcPopoverButtonClass))

typedef struct _DcPopoverButton DcPopoverButton;
typedef struct _DcPopoverButtonClass DcPopoverButtonClass;
typedef struct _Block62Data Block62Data;
typedef struct _DcStickerManagerDialogConfirmDeleteStickerData DcStickerManagerDialogConfirmDeleteStickerData;
typedef struct _Block63Data Block63Data;
typedef struct _DcStickerManagerDialogOnDeletePackData DcStickerManagerDialogOnDeletePackData;

struct _DcStickerManagerDialog {
	AdwDialog parent_instance;
	DcStickerManagerDialogPrivate * priv;
};

struct _DcStickerManagerDialogClass {
	AdwDialogClass parent_class;
};

struct _DcStickerManagerDialogPrivate {
	DcWindow* app_window;
	GtkDropDown* pack_dropdown;
	GtkFlowBox* sticker_grid;
	GtkLabel* placeholder;
	GtkButton* rename_pack_btn;
	GtkButton* delete_pack_btn;
	gchar** packs;
	gint packs_length1;
	gint _packs_size_;
	gboolean syncing_packs;
};

struct _DcStickerManagerDialogPromptNewPackData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GtkWidget* parent;
	gchar* result;
	AdwAlertDialog* d;
	AdwAlertDialog* _tmp0_;
	AdwAlertDialog* _tmp1_;
	AdwAlertDialog* _tmp2_;
	AdwAlertDialog* _tmp3_;
	AdwAlertDialog* _tmp4_;
	AdwAlertDialog* _tmp5_;
	GtkEntry* entry;
	GtkEntry* _tmp6_;
	GtkEntry* _tmp7_;
	GtkEntry* _tmp8_;
	AdwAlertDialog* _tmp9_;
	GtkEntry* _tmp10_;
	gchar* response;
	AdwAlertDialog* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	const gchar* _tmp14_;
	GtkEntry* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
};

struct _Block58Data {
	int _ref_count_;
	gchar** packs;
	gint packs_length1;
	gint _packs_size_;
	GtkDropDown* dropdown;
	GtkEntry* entry;
	DcWindow* window;
	gchar* file_path;
};

struct _Block59Data {
	int _ref_count_;
	DcStickerManagerDialog* self;
	GtkBox* card;
	GtkButton* emoji_btn;
	DcSticker* sticker;
};

struct _DcSticker {
	GObject parent_instance;
	DcStickerPrivate * priv;
	gchar* file_name;
	gchar* pack;
	gchar* emoji;
	gchar* display_name;
};

struct _DcStickerClass {
	GObjectClass parent_class;
};

struct _Block60Data {
	int _ref_count_;
	DcStickerManagerDialog* self;
	DcSticker* sticker;
	GtkButton* btn;
};

struct _Block61Data {
	int _ref_count_;
	DcStickerManagerDialog* self;
	DcSticker* sticker;
};

struct _Block62Data {
	int _ref_count_;
	Block61Data * _data61_;
	gchar* dest;
};

struct _DcStickerManagerDialogConfirmDeleteStickerData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcStickerManagerDialog* self;
	DcSticker* sticker;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gboolean _tmp3_;
};

struct _Block63Data {
	int _ref_count_;
	DcStickerManagerDialog* self;
	gchar* pack;
	GtkEntry* entry;
};

struct _DcStickerManagerDialogOnDeletePackData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcStickerManagerDialog* self;
	gchar* pack;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gboolean _tmp5_;
	const gchar* _tmp6_;
};

static gint DcStickerManagerDialog_private_offset;
static gpointer dc_sticker_manager_dialog_parent_class = NULL;

VALA_EXTERN GType dc_sticker_manager_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcStickerManagerDialog, 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 DcStickerManagerDialog* dc_sticker_manager_dialog_new (DcWindow* window);
VALA_EXTERN DcStickerManagerDialog* dc_sticker_manager_dialog_construct (GType object_type,
                                                             DcWindow* window);
static void __lambda105_ (DcStickerManagerDialog* self);
VALA_EXTERN void dc_sticker_manager_dialog_prompt_new_pack (GtkWidget* parent,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN gchar* dc_sticker_manager_dialog_prompt_new_pack_finish (GAsyncResult* _res_);
static void __lambda106_ (DcStickerManagerDialog* self,
                   GObject* obj,
                   GAsyncResult* res);
static void dc_sticker_manager_dialog_add_session_pack (DcStickerManagerDialog* self,
                                                 const gchar* pack);
static void ___lambda106__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void ___lambda105__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda113_ (DcStickerManagerDialog* self);
static void dc_sticker_manager_dialog_reload_stickers (DcStickerManagerDialog* self);
static void ___lambda113__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void dc_sticker_manager_dialog_on_rename_pack (DcStickerManagerDialog* self);
static void _dc_sticker_manager_dialog_on_rename_pack_gtk_button_clicked (GtkButton* _sender,
                                                                   gpointer self);
static void __lambda115_ (DcStickerManagerDialog* self);
static void dc_sticker_manager_dialog_on_delete_pack (DcStickerManagerDialog* self,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static void dc_sticker_manager_dialog_on_delete_pack_finish (DcStickerManagerDialog* self,
                                                      GAsyncResult* _res_);
static void ___lambda115__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_sticker_manager_dialog_reload_packs (DcStickerManagerDialog* self,
                                             const gchar* select_pack);
static void dc_sticker_manager_dialog_prompt_new_pack_data_free (gpointer _data);
static gboolean dc_sticker_manager_dialog_prompt_new_pack_co (DcStickerManagerDialogPromptNewPackData* _data_);
static void dc_sticker_manager_dialog_prompt_new_pack_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
VALA_EXTERN gchar* dc_sticker_store_sanitize_pack_name (const gchar* name);
VALA_EXTERN void dc_sticker_manager_dialog_prompt_add_sticker (DcWindow* window,
                                                   const gchar* file_path);
static Block58Data* block58_data_ref (Block58Data* _data58_);
static void block58_data_unref (void * _userdata_);
VALA_EXTERN gchar** dc_sticker_store_list_packs (gint* result_length1);
static gchar** _vala_array_dup16 (gchar** self,
                           gssize length);
static void _vala_array_add44 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void __lambda116_ (Block58Data* _data58_);
static void ___lambda116__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda117_ (Block58Data* _data58_,
                   const gchar* r);
VALA_EXTERN void dc_window_show_toast (DcWindow* self,
                           const gchar* message);
VALA_EXTERN gboolean dc_sticker_store_add_sticker (const gchar* pack,
                                       const gchar* source_path,
                                       GError** error);
VALA_EXTERN void dc_show_error (GtkWidget* parent,
                    const gchar* message);
static void ___lambda117__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                              const gchar* response,
                                              gpointer self);
static void dc_sticker_manager_dialog_show_packs (DcStickerManagerDialog* self,
                                           gchar** new_packs,
                                           gint new_packs_length1,
                                           const gchar* select_pack);
static void _vala_array_add45 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static gchar* dc_sticker_manager_dialog_selected_pack (DcStickerManagerDialog* self);
static gchar** _vala_array_dup17 (gchar** self,
                           gssize length);
VALA_EXTERN GType dc_sticker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSticker, g_object_unref)
VALA_EXTERN DcSticker** dc_sticker_store_list_stickers (const gchar* pack,
                                            gint* result_length1);
static GtkWidget* dc_sticker_manager_dialog_build_sticker_card (DcStickerManagerDialog* self,
                                                         DcSticker* sticker);
static Block59Data* block59_data_ref (Block59Data* _data59_);
static void block59_data_unref (void * _userdata_);
VALA_EXTERN GtkWidget* dc_sticker_thumbnail (const gchar* path,
                                 gint scale_factor,
                                 gint size);
VALA_EXTERN gchar* dc_sticker_store_sticker_path (const gchar* file_name);
static void __lambda107_ (Block59Data* _data59_);
static void dc_sticker_manager_dialog_pick_emoji (DcStickerManagerDialog* self,
                                           DcSticker* sticker,
                                           GtkButton* btn);
static void ___lambda107__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda109_ (Block59Data* _data59_,
                   gint n,
                   gdouble x,
                   gdouble y);
static void dc_sticker_manager_dialog_show_sticker_menu (DcStickerManagerDialog* self,
                                                  DcSticker* sticker,
                                                  GtkWidget* parent,
                                                  gdouble x,
                                                  gdouble y);
static void ___lambda109__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self);
static Block60Data* block60_data_ref (Block60Data* _data60_);
static void block60_data_unref (void * _userdata_);
VALA_EXTERN GtkEmojiChooser* dc_create_emoji_chooser (void);
static void __lambda108_ (Block60Data* _data60_,
                   const gchar* emoji);
VALA_EXTERN void dc_sticker_store_set_emoji (DcSticker* sticker,
                                 const gchar* emoji,
                                 GError** error);
static void ___lambda108__gtk_emoji_chooser_emoji_picked (GtkEmojiChooser* _sender,
                                                   const gchar* text,
                                                   gpointer self);
VALA_EXTERN void dc_unparent_on_close (GtkPopover* popover);
static Block61Data* block61_data_ref (Block61Data* _data61_);
static void block61_data_unref (void * _userdata_);
VALA_EXTERN GtkPopover* dc_popover_menu (GtkWidget* parent,
                             gdouble x,
                             gdouble y,
                             GtkBox** vbox);
VALA_EXTERN GType dc_popover_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcPopoverButton, g_object_unref)
VALA_EXTERN DcPopoverButton* dc_popover_button_new (GtkPopover* popover,
                                        const gchar* label,
                                        gboolean destructive,
                                        gboolean hexpand);
VALA_EXTERN DcPopoverButton* dc_popover_button_construct (GType object_type,
                                              GtkPopover* popover,
                                              const gchar* label,
                                              gboolean destructive,
                                              gboolean hexpand);
static void __lambda110_ (Block61Data* _data61_);
static void ___lambda110__dc_popover_button_selected (DcPopoverButton* _sender,
                                               gpointer self);
static Block62Data* block62_data_ref (Block62Data* _data62_);
static void block62_data_unref (void * _userdata_);
static void ____lambda111_ (Block62Data* _data62_);
VALA_EXTERN gboolean dc_sticker_store_move_sticker (DcSticker* sticker,
                                        const gchar* dest_pack,
                                        GError** error);
static void _____lambda111__dc_popover_button_selected (DcPopoverButton* _sender,
                                                 gpointer self);
static void __lambda112_ (Block61Data* _data61_);
static void dc_sticker_manager_dialog_confirm_delete_sticker (DcStickerManagerDialog* self,
                                                       DcSticker* sticker,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
static void dc_sticker_manager_dialog_confirm_delete_sticker_finish (DcStickerManagerDialog* self,
                                                              GAsyncResult* _res_);
static void ___lambda112__dc_popover_button_selected (DcPopoverButton* _sender,
                                               gpointer self);
static void dc_sticker_manager_dialog_confirm_delete_sticker_data_free (gpointer _data);
static gboolean dc_sticker_manager_dialog_confirm_delete_sticker_co (DcStickerManagerDialogConfirmDeleteStickerData* _data_);
VALA_EXTERN void dc_confirm_action (GtkWidget* parent,
                        const gchar* title,
                        const gchar* body,
                        const gchar* action_id,
                        const gchar* action_label,
                        GAsyncReadyCallback _callback_,
                        gpointer _user_data_);
VALA_EXTERN gboolean dc_confirm_action_finish (GAsyncResult* _res_);
static void dc_sticker_manager_dialog_confirm_delete_sticker_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_);
VALA_EXTERN void dc_sticker_store_delete_sticker (DcSticker* sticker);
static Block63Data* block63_data_ref (Block63Data* _data63_);
static void block63_data_unref (void * _userdata_);
static void __lambda114_ (Block63Data* _data63_,
                   const gchar* r);
VALA_EXTERN void dc_sticker_store_rename_pack (const gchar* pack,
                                   const gchar* new_pack,
                                   GError** error);
static void _vala_array_add46 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void ___lambda114__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                              const gchar* response,
                                              gpointer self);
static void dc_sticker_manager_dialog_on_delete_pack_data_free (gpointer _data);
static gboolean dc_sticker_manager_dialog_on_delete_pack_co (DcStickerManagerDialogOnDeletePackData* _data_);
static void dc_sticker_manager_dialog_on_delete_pack_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_);
VALA_EXTERN void dc_sticker_store_delete_pack (const gchar* pack);
static void dc_sticker_manager_dialog_finalize (GObject * obj);
static GType dc_sticker_manager_dialog_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dc_sticker_manager_dialog_get_instance_private (DcStickerManagerDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcStickerManagerDialog_private_offset);
}

static void
__lambda106_ (DcStickerManagerDialog* self,
              GObject* obj,
              GAsyncResult* res)
{
	gchar* pack = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (res != NULL);
	_tmp0_ = dc_sticker_manager_dialog_prompt_new_pack_finish (res);
	pack = _tmp0_;
	_tmp1_ = pack;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		_tmp2_ = pack;
		dc_sticker_manager_dialog_add_session_pack (self, _tmp2_);
	}
	_g_free0 (pack);
}

static void
___lambda106__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda106_ ((DcStickerManagerDialog*) self, source_object, res);
	g_object_unref (self);
}

static void
__lambda105_ (DcStickerManagerDialog* self)
{
	dc_sticker_manager_dialog_prompt_new_pack ((GtkWidget*) self, ___lambda106__gasync_ready_callback, g_object_ref (self));
}

static void
___lambda105__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda105_ ((DcStickerManagerDialog*) self);
}

static void
__lambda113_ (DcStickerManagerDialog* self)
{
	if (!self->priv->syncing_packs) {
		dc_sticker_manager_dialog_reload_stickers (self);
	}
}

static void
___lambda113__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda113_ ((DcStickerManagerDialog*) self);
}

static void
_dc_sticker_manager_dialog_on_rename_pack_gtk_button_clicked (GtkButton* _sender,
                                                              gpointer self)
{
	dc_sticker_manager_dialog_on_rename_pack ((DcStickerManagerDialog*) self);
}

static void
__lambda115_ (DcStickerManagerDialog* self)
{
	dc_sticker_manager_dialog_on_delete_pack (self, NULL, NULL);
}

static void
___lambda115__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda115_ ((DcStickerManagerDialog*) self);
}

DcStickerManagerDialog*
dc_sticker_manager_dialog_construct (GType object_type,
                                     DcWindow* window)
{
	DcStickerManagerDialog * self = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	AdwHeaderBar* header = NULL;
	AdwHeaderBar* _tmp1_;
	GtkBox* content = NULL;
	GtkBox* _tmp2_;
	GtkBox* pack_row = NULL;
	GtkBox* _tmp3_;
	GtkButton* add_pack_btn = NULL;
	GtkButton* _tmp4_;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	GtkDropDown* _tmp7_;
	GtkDropDown* _tmp8_;
	GtkDropDown* _tmp9_;
	GtkDropDown* _tmp10_;
	GtkButton* _tmp11_;
	GtkButton* _tmp12_;
	GtkButton* _tmp13_;
	GtkButton* _tmp14_;
	GtkButton* _tmp15_;
	GtkButton* _tmp16_;
	GtkButton* _tmp17_;
	GtkButton* _tmp18_;
	GtkLabel* _tmp19_;
	GtkLabel* _tmp20_;
	GtkLabel* _tmp21_;
	GtkLabel* _tmp22_;
	GtkLabel* _tmp23_;
	GtkLabel* _tmp24_;
	GtkLabel* _tmp25_;
	GtkLabel* _tmp26_;
	GtkFlowBox* _tmp27_;
	GtkFlowBox* _tmp28_;
	GtkFlowBox* _tmp29_;
	GtkFlowBox* _tmp30_;
	GtkFlowBox* _tmp31_;
	GtkFlowBox* _tmp32_;
	GtkFlowBox* _tmp33_;
	GtkFlowBox* _tmp34_;
	GtkBox* grid_box = NULL;
	GtkBox* _tmp35_;
	GtkLabel* _tmp36_;
	GtkFlowBox* _tmp37_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp38_;
	g_return_val_if_fail (window != NULL, NULL);
	self = (DcStickerManagerDialog*) g_object_new (object_type, NULL);
	self->priv->app_window = window;
	adw_dialog_set_title ((AdwDialog*) self, "Stickers");
	adw_dialog_set_content_width ((AdwDialog*) self, 420);
	adw_dialog_set_content_height ((AdwDialog*) self, 520);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp1_);
	header = _tmp1_;
	adw_header_bar_set_show_end_title_buttons (header, TRUE);
	gtk_box_append (box, (GtkWidget*) header);
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp2_);
	content = _tmp2_;
	gtk_widget_set_margin_start ((GtkWidget*) content, 16);
	gtk_widget_set_margin_end ((GtkWidget*) content, 16);
	gtk_widget_set_margin_top ((GtkWidget*) content, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) content, 16);
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp3_);
	pack_row = _tmp3_;
	_tmp4_ = (GtkButton*) gtk_button_new_from_icon_name ("list-add-symbolic");
	g_object_ref_sink (_tmp4_);
	add_pack_btn = _tmp4_;
	gtk_widget_set_tooltip_text ((GtkWidget*) add_pack_btn, "Create a new sticker pack");
	g_signal_connect_object (add_pack_btn, "clicked", (GCallback) ___lambda105__gtk_button_clicked, self, 0);
	gtk_box_append (pack_row, (GtkWidget*) add_pack_btn);
	_tmp5_ = g_new0 (gchar*, 0 + 1);
	_tmp6_ = _tmp5_;
	_tmp6__length1 = 0;
	_tmp7_ = (GtkDropDown*) gtk_drop_down_new_from_strings (_tmp6_);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->pack_dropdown);
	self->priv->pack_dropdown = _tmp7_;
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_free), NULL);
	_tmp8_ = self->priv->pack_dropdown;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp8_, TRUE);
	_tmp9_ = self->priv->pack_dropdown;
	g_signal_connect_object ((GObject*) _tmp9_, "notify::selected", (GCallback) ___lambda113__g_object_notify, self, 0);
	_tmp10_ = self->priv->pack_dropdown;
	gtk_box_append (pack_row, (GtkWidget*) _tmp10_);
	_tmp11_ = (GtkButton*) gtk_button_new_from_icon_name ("document-edit-symbolic");
	g_object_ref_sink (_tmp11_);
	_g_object_unref0 (self->priv->rename_pack_btn);
	self->priv->rename_pack_btn = _tmp11_;
	_tmp12_ = self->priv->rename_pack_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp12_, "Rename the selected pack");
	_tmp13_ = self->priv->rename_pack_btn;
	g_signal_connect_object (_tmp13_, "clicked", (GCallback) _dc_sticker_manager_dialog_on_rename_pack_gtk_button_clicked, self, 0);
	_tmp14_ = self->priv->rename_pack_btn;
	gtk_box_append (pack_row, (GtkWidget*) _tmp14_);
	_tmp15_ = (GtkButton*) gtk_button_new_from_icon_name ("list-remove-symbolic");
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->delete_pack_btn);
	self->priv->delete_pack_btn = _tmp15_;
	_tmp16_ = self->priv->delete_pack_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp16_, "Delete the selected pack and all of its stickers");
	_tmp17_ = self->priv->delete_pack_btn;
	g_signal_connect_object (_tmp17_, "clicked", (GCallback) ___lambda115__gtk_button_clicked, self, 0);
	_tmp18_ = self->priv->delete_pack_btn;
	gtk_box_append (pack_row, (GtkWidget*) _tmp18_);
	gtk_box_append (content, (GtkWidget*) pack_row);
	_tmp19_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->placeholder);
	self->priv->placeholder = _tmp19_;
	_tmp20_ = self->priv->placeholder;
	gtk_widget_add_css_class ((GtkWidget*) _tmp20_, "dim-label");
	_tmp21_ = self->priv->placeholder;
	gtk_label_set_wrap (_tmp21_, TRUE);
	_tmp22_ = self->priv->placeholder;
	gtk_label_set_justify (_tmp22_, GTK_JUSTIFY_CENTER);
	_tmp23_ = self->priv->placeholder;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp23_, 24);
	_tmp24_ = self->priv->placeholder;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp24_, 24);
	_tmp25_ = self->priv->placeholder;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp25_, 12);
	_tmp26_ = self->priv->placeholder;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp26_, 12);
	_tmp27_ = (GtkFlowBox*) gtk_flow_box_new ();
	g_object_ref_sink (_tmp27_);
	_g_object_unref0 (self->priv->sticker_grid);
	self->priv->sticker_grid = _tmp27_;
	_tmp28_ = self->priv->sticker_grid;
	gtk_flow_box_set_selection_mode (_tmp28_, GTK_SELECTION_NONE);
	_tmp29_ = self->priv->sticker_grid;
	gtk_flow_box_set_min_children_per_line (_tmp29_, (guint) 3);
	_tmp30_ = self->priv->sticker_grid;
	gtk_flow_box_set_max_children_per_line (_tmp30_, (guint) 3);
	_tmp31_ = self->priv->sticker_grid;
	gtk_flow_box_set_homogeneous (_tmp31_, TRUE);
	_tmp32_ = self->priv->sticker_grid;
	gtk_flow_box_set_column_spacing (_tmp32_, (guint) 8);
	_tmp33_ = self->priv->sticker_grid;
	gtk_flow_box_set_row_spacing (_tmp33_, (guint) 8);
	_tmp34_ = self->priv->sticker_grid;
	gtk_widget_set_valign ((GtkWidget*) _tmp34_, GTK_ALIGN_START);
	_tmp35_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp35_);
	grid_box = _tmp35_;
	_tmp36_ = self->priv->placeholder;
	gtk_box_append (grid_box, (GtkWidget*) _tmp36_);
	_tmp37_ = self->priv->sticker_grid;
	gtk_box_append (grid_box, (GtkWidget*) _tmp37_);
	_tmp38_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp38_);
	scroll = _tmp38_;
	gtk_widget_set_vexpand ((GtkWidget*) scroll, TRUE);
	g_object_set (scroll, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_scrolled_window_set_child (scroll, (GtkWidget*) grid_box);
	gtk_box_append (content, (GtkWidget*) scroll);
	gtk_box_append (box, (GtkWidget*) content);
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) box);
	dc_sticker_manager_dialog_reload_packs (self, NULL);
	_g_object_unref0 (scroll);
	_g_object_unref0 (grid_box);
	_g_object_unref0 (add_pack_btn);
	_g_object_unref0 (pack_row);
	_g_object_unref0 (content);
	_g_object_unref0 (header);
	_g_object_unref0 (box);
	return self;
}

DcStickerManagerDialog*
dc_sticker_manager_dialog_new (DcWindow* window)
{
	return dc_sticker_manager_dialog_construct (DC_TYPE_STICKER_MANAGER_DIALOG, window);
}

static void
dc_sticker_manager_dialog_prompt_new_pack_data_free (gpointer _data)
{
	DcStickerManagerDialogPromptNewPackData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->parent);
	_g_free0 (_data_->result);
	g_slice_free (DcStickerManagerDialogPromptNewPackData, _data_);
}

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

void
dc_sticker_manager_dialog_prompt_new_pack (GtkWidget* parent,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	DcStickerManagerDialogPromptNewPackData* _data_;
	GtkWidget* _tmp0_;
	g_return_if_fail (parent != NULL);
	_data_ = g_slice_new0 (DcStickerManagerDialogPromptNewPackData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_sticker_manager_dialog_prompt_new_pack_data_free);
	_tmp0_ = _g_object_ref0 (parent);
	_g_object_unref0 (_data_->parent);
	_data_->parent = _tmp0_;
	dc_sticker_manager_dialog_prompt_new_pack_co (_data_);
}

gchar*
dc_sticker_manager_dialog_prompt_new_pack_finish (GAsyncResult* _res_)
{
	gchar* result;
	DcStickerManagerDialogPromptNewPackData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
dc_sticker_manager_dialog_prompt_new_pack_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	DcStickerManagerDialogPromptNewPackData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_sticker_manager_dialog_prompt_new_pack_co (_data_);
}

static gboolean
dc_sticker_manager_dialog_prompt_new_pack_co (DcStickerManagerDialogPromptNewPackData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = (AdwAlertDialog*) adw_alert_dialog_new ("New Sticker Pack", "Name for the new sticker pack.");
	g_object_ref_sink (_data_->_tmp0_);
	_data_->d = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->d;
	adw_alert_dialog_add_response (_data_->_tmp1_, "cancel", "Cancel");
	_data_->_tmp2_ = _data_->d;
	adw_alert_dialog_add_response (_data_->_tmp2_, "create", "Create");
	_data_->_tmp3_ = _data_->d;
	adw_alert_dialog_set_response_appearance (_data_->_tmp3_, "create", ADW_RESPONSE_SUGGESTED);
	_data_->_tmp4_ = _data_->d;
	adw_alert_dialog_set_default_response (_data_->_tmp4_, "create");
	_data_->_tmp5_ = _data_->d;
	adw_alert_dialog_set_close_response (_data_->_tmp5_, "cancel");
	_data_->_tmp6_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_data_->_tmp6_);
	_data_->entry = _data_->_tmp6_;
	_data_->_tmp7_ = _data_->entry;
	gtk_entry_set_placeholder_text (_data_->_tmp7_, "Pack name");
	_data_->_tmp8_ = _data_->entry;
	gtk_entry_set_activates_default (_data_->_tmp8_, TRUE);
	_data_->_tmp9_ = _data_->d;
	_data_->_tmp10_ = _data_->entry;
	adw_alert_dialog_set_extra_child (_data_->_tmp9_, (GtkWidget*) _data_->_tmp10_);
	_data_->_tmp11_ = _data_->d;
	_data_->_state_ = 1;
	adw_alert_dialog_choose (_data_->_tmp11_, _data_->parent, NULL, dc_sticker_manager_dialog_prompt_new_pack_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp12_ = adw_alert_dialog_choose_finish (_data_->_tmp11_, _data_->_res_);
	_data_->_tmp13_ = g_strdup (_data_->_tmp12_);
	_data_->response = _data_->_tmp13_;
	_data_->_tmp14_ = _data_->response;
	if (g_strcmp0 (_data_->_tmp14_, "create") != 0) {
		_data_->result = NULL;
		_g_free0 (_data_->response);
		_g_object_unref0 (_data_->entry);
		_g_object_unref0 (_data_->d);
		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_->_tmp15_ = _data_->entry;
	_data_->_tmp16_ = gtk_editable_get_text ((GtkEditable*) _data_->_tmp15_);
	_data_->_tmp17_ = _data_->_tmp16_;
	_data_->_tmp18_ = dc_sticker_store_sanitize_pack_name (_data_->_tmp17_);
	_data_->result = _data_->_tmp18_;
	_g_free0 (_data_->response);
	_g_object_unref0 (_data_->entry);
	_g_object_unref0 (_data_->d);
	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;
}

/** Ask for the destination pack (existing or new) and copy the
            sticker file into it. */
static Block58Data*
block58_data_ref (Block58Data* _data58_)
{
	g_atomic_int_inc (&_data58_->_ref_count_);
	return _data58_;
}

static void
block58_data_unref (void * _userdata_)
{
	Block58Data* _data58_;
	_data58_ = (Block58Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data58_->_ref_count_)) {
		_g_object_unref0 (_data58_->entry);
		_g_object_unref0 (_data58_->dropdown);
		_data58_->packs = (_vala_array_free (_data58_->packs, _data58_->packs_length1, (GDestroyNotify) g_free), NULL);
		_g_object_unref0 (_data58_->window);
		_g_free0 (_data58_->file_path);
		g_slice_free (Block58Data, _data58_);
	}
}

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

static void
_vala_array_add44 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
__lambda116_ (Block58Data* _data58_)
{
	guint _tmp0_;
	guint _tmp1_;
	_tmp0_ = gtk_drop_down_get_selected (_data58_->dropdown);
	_tmp1_ = _tmp0_;
	gtk_widget_set_visible ((GtkWidget*) _data58_->entry, _tmp1_ == ((guint) _data58_->packs_length1));
}

static void
___lambda116__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda116_ (self);
}

static void
__lambda117_ (Block58Data* _data58_,
              const gchar* r)
{
	gchar* pack = NULL;
	guint _tmp0_;
	guint _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (r != NULL);
	if (g_strcmp0 (r, "add") != 0) {
		return;
	}
	_tmp0_ = gtk_drop_down_get_selected (_data58_->dropdown);
	_tmp1_ = _tmp0_;
	if (_tmp1_ < ((guint) _data58_->packs_length1)) {
		guint _tmp2_;
		guint _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp2_ = gtk_drop_down_get_selected (_data58_->dropdown);
		_tmp3_ = _tmp2_;
		_tmp4_ = _data58_->packs[_tmp3_];
		_tmp5_ = g_strdup (_tmp4_);
		_g_free0 (pack);
		pack = _tmp5_;
	} else {
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		const gchar* _tmp9_;
		_tmp6_ = gtk_editable_get_text ((GtkEditable*) _data58_->entry);
		_tmp7_ = _tmp6_;
		_tmp8_ = dc_sticker_store_sanitize_pack_name (_tmp7_);
		_g_free0 (pack);
		pack = _tmp8_;
		_tmp9_ = pack;
		if (_tmp9_ == NULL) {
			dc_window_show_toast (_data58_->window, "Enter a name for the new sticker pack");
			_g_free0 (pack);
			return;
		}
	}
	{
		gchar* _tmp10_ = NULL;
		gboolean _tmp11_ = FALSE;
		const gchar* _tmp12_;
		_tmp12_ = pack;
		_tmp11_ = dc_sticker_store_add_sticker (_tmp12_, _data58_->file_path, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (_tmp10_);
			goto __catch0_g_error;
		}
		if (_tmp11_) {
			const gchar* _tmp13_;
			gchar* _tmp14_;
			_tmp13_ = pack;
			_tmp14_ = g_strdup_printf ("Sticker added to \"%s\"", _tmp13_);
			_g_free0 (_tmp10_);
			_tmp10_ = _tmp14_;
		} else {
			const gchar* _tmp15_;
			gchar* _tmp16_;
			_tmp15_ = pack;
			_tmp16_ = g_strdup_printf ("Sticker is already in \"%s\"", _tmp15_);
			_g_free0 (_tmp10_);
			_tmp10_ = _tmp16_;
		}
		dc_window_show_toast (_data58_->window, _tmp10_);
		_g_free0 (_tmp10_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp17_;
		const gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp17_ = e;
		_tmp18_ = _tmp17_->message;
		_tmp19_ = g_strconcat ("Could not add sticker: ", _tmp18_, NULL);
		_tmp20_ = _tmp19_;
		dc_show_error ((GtkWidget*) _data58_->window, _tmp20_);
		_g_free0 (_tmp20_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (pack);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_g_free0 (pack);
}

static void
___lambda117__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                         const gchar* response,
                                         gpointer self)
{
	__lambda117_ (self, response);
}

void
dc_sticker_manager_dialog_prompt_add_sticker (DcWindow* window,
                                              const gchar* file_path)
{
	Block58Data* _data58_;
	DcWindow* _tmp0_;
	gchar* _tmp1_;
	gint _tmp2_ = 0;
	gchar** _tmp3_;
	AdwAlertDialog* d = NULL;
	AdwAlertDialog* _tmp4_;
	gchar** choices = NULL;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gint choices_length1;
	gint _choices_size_;
	gchar* _tmp6_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	GtkDropDown* _tmp8_;
	GtkEntry* _tmp9_;
	GtkBox* box = NULL;
	GtkBox* _tmp10_;
	g_return_if_fail (window != NULL);
	g_return_if_fail (file_path != NULL);
	_data58_ = g_slice_new0 (Block58Data);
	_data58_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (window);
	_g_object_unref0 (_data58_->window);
	_data58_->window = _tmp0_;
	_tmp1_ = g_strdup (file_path);
	_g_free0 (_data58_->file_path);
	_data58_->file_path = _tmp1_;
	_tmp3_ = dc_sticker_store_list_packs (&_tmp2_);
	_data58_->packs = _tmp3_;
	_data58_->packs_length1 = _tmp2_;
	_data58_->_packs_size_ = _data58_->packs_length1;
	_tmp4_ = (AdwAlertDialog*) adw_alert_dialog_new ("Add Sticker", "Choose the sticker pack to add this sticker to.");
	g_object_ref_sink (_tmp4_);
	d = _tmp4_;
	adw_alert_dialog_add_response (d, "cancel", "Cancel");
	adw_alert_dialog_add_response (d, "add", "Add");
	adw_alert_dialog_set_response_appearance (d, "add", ADW_RESPONSE_SUGGESTED);
	adw_alert_dialog_set_default_response (d, "add");
	adw_alert_dialog_set_close_response (d, "cancel");
	_tmp5_ = (_data58_->packs != NULL) ? _vala_array_dup16 (_data58_->packs, _data58_->packs_length1) : _data58_->packs;
	_tmp5__length1 = _data58_->packs_length1;
	choices = _tmp5_;
	choices_length1 = _tmp5__length1;
	_choices_size_ = choices_length1;
	_tmp6_ = g_strdup ("New pack…");
	_vala_array_add44 (&choices, &choices_length1, &_choices_size_, _tmp6_);
	_tmp7_ = choices;
	_tmp7__length1 = choices_length1;
	_tmp8_ = (GtkDropDown*) gtk_drop_down_new_from_strings (_tmp7_);
	g_object_ref_sink (_tmp8_);
	_data58_->dropdown = _tmp8_;
	gtk_drop_down_set_selected (_data58_->dropdown, (guint) 0);
	_tmp9_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp9_);
	_data58_->entry = _tmp9_;
	gtk_entry_set_placeholder_text (_data58_->entry, "New pack name");
	gtk_entry_set_activates_default (_data58_->entry, TRUE);
	gtk_widget_set_visible ((GtkWidget*) _data58_->entry, _data58_->packs_length1 == 0);
	g_signal_connect_data ((GObject*) _data58_->dropdown, "notify::selected", (GCallback) ___lambda116__g_object_notify, block58_data_ref (_data58_), (GClosureNotify) block58_data_unref, 0);
	_tmp10_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	g_object_ref_sink (_tmp10_);
	box = _tmp10_;
	gtk_box_append (box, (GtkWidget*) _data58_->dropdown);
	gtk_box_append (box, (GtkWidget*) _data58_->entry);
	adw_alert_dialog_set_extra_child (d, (GtkWidget*) box);
	g_signal_connect_data (d, "response", (GCallback) ___lambda117__adw_alert_dialog_response, block58_data_ref (_data58_), (GClosureNotify) block58_data_unref, 0);
	adw_dialog_present ((AdwDialog*) d, (GtkWidget*) _data58_->window);
	_g_object_unref0 (box);
	choices = (_vala_array_free (choices, choices_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (d);
	block58_data_unref (_data58_);
	_data58_ = NULL;
}

static void
dc_sticker_manager_dialog_reload_packs (DcStickerManagerDialog* self,
                                        const gchar* select_pack)
{
	gint _tmp0_ = 0;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	g_return_if_fail (self != NULL);
	_tmp1_ = dc_sticker_store_list_packs (&_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp0_;
	dc_sticker_manager_dialog_show_packs (self, _tmp2_, (gint) _tmp0_, select_pack);
	_tmp2_ = (_vala_array_free (_tmp2_, _tmp2__length1, (GDestroyNotify) g_free), NULL);
}

static void
_vala_array_add45 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
dc_sticker_manager_dialog_add_session_pack (DcStickerManagerDialog* self,
                                            const gchar* pack)
{
	gboolean known = FALSE;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp4_;
	gint _tmp4__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pack != NULL);
	known = FALSE;
	_tmp0_ = self->priv->packs;
	_tmp0__length1 = self->priv->packs_length1;
	{
		gchar** existing_collection = NULL;
		gint existing_collection_length1 = 0;
		gint _existing_collection_size_ = 0;
		gint existing_it = 0;
		existing_collection = _tmp0_;
		existing_collection_length1 = _tmp0__length1;
		for (existing_it = 0; existing_it < existing_collection_length1; existing_it = existing_it + 1) {
			gchar* _tmp1_;
			gchar* existing = NULL;
			_tmp1_ = g_strdup (existing_collection[existing_it]);
			existing = _tmp1_;
			{
				const gchar* _tmp2_;
				_tmp2_ = existing;
				if (g_strcmp0 (_tmp2_, pack) == 0) {
					known = TRUE;
				}
				_g_free0 (existing);
			}
		}
	}
	if (!known) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup (pack);
		_vala_array_add45 (&self->priv->packs, &self->priv->packs_length1, &self->priv->_packs_size_, _tmp3_);
	}
	_tmp4_ = self->priv->packs;
	_tmp4__length1 = self->priv->packs_length1;
	dc_sticker_manager_dialog_show_packs (self, _tmp4_, (gint) _tmp4__length1, pack);
}

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

static void
dc_sticker_manager_dialog_show_packs (DcStickerManagerDialog* self,
                                      gchar** new_packs,
                                      gint new_packs_length1,
                                      const gchar* select_pack)
{
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar* want = NULL;
	gchar* _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	GtkDropDown* _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	GtkStringList* _tmp7_;
	GtkStringList* _tmp8_;
	GtkDropDown* _tmp16_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	GtkButton* _tmp18_;
	gchar** _tmp19_;
	gint _tmp19__length1;
	GtkButton* _tmp20_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	g_return_if_fail (self != NULL);
	_tmp1_ = g_strdup (select_pack);
	_tmp0_ = _tmp1_;
	if (_tmp0_ == NULL) {
		gchar* _tmp2_;
		_tmp2_ = dc_sticker_manager_dialog_selected_pack (self);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp2_;
	}
	_tmp3_ = _tmp0_;
	_tmp0_ = NULL;
	want = _tmp3_;
	_tmp4_ = (new_packs != NULL) ? _vala_array_dup17 (new_packs, new_packs_length1) : new_packs;
	_tmp4__length1 = new_packs_length1;
	self->priv->packs = (_vala_array_free (self->priv->packs, self->priv->packs_length1, (GDestroyNotify) g_free), NULL);
	self->priv->packs = _tmp4_;
	self->priv->packs_length1 = _tmp4__length1;
	self->priv->_packs_size_ = self->priv->packs_length1;
	self->priv->syncing_packs = TRUE;
	_tmp5_ = self->priv->pack_dropdown;
	_tmp6_ = self->priv->packs;
	_tmp6__length1 = self->priv->packs_length1;
	_tmp7_ = gtk_string_list_new (_tmp6_);
	_tmp8_ = _tmp7_;
	gtk_drop_down_set_model (_tmp5_, (GListModel*) _tmp8_);
	_g_object_unref0 (_tmp8_);
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				gchar** _tmp11_;
				gint _tmp11__length1;
				gchar** _tmp12_;
				gint _tmp12__length1;
				const gchar* _tmp13_;
				const gchar* _tmp14_;
				if (!_tmp9_) {
					guint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp11_ = self->priv->packs;
				_tmp11__length1 = self->priv->packs_length1;
				if (!(i < ((guint) _tmp11__length1))) {
					break;
				}
				_tmp12_ = self->priv->packs;
				_tmp12__length1 = self->priv->packs_length1;
				_tmp13_ = _tmp12_[i];
				_tmp14_ = want;
				if (g_strcmp0 (_tmp13_, _tmp14_) == 0) {
					GtkDropDown* _tmp15_;
					_tmp15_ = self->priv->pack_dropdown;
					gtk_drop_down_set_selected (_tmp15_, i);
					break;
				}
			}
		}
	}
	self->priv->syncing_packs = FALSE;
	_tmp16_ = self->priv->pack_dropdown;
	_tmp17_ = self->priv->packs;
	_tmp17__length1 = self->priv->packs_length1;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp16_, _tmp17__length1 > 0);
	_tmp18_ = self->priv->rename_pack_btn;
	_tmp19_ = self->priv->packs;
	_tmp19__length1 = self->priv->packs_length1;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp18_, _tmp19__length1 > 0);
	_tmp20_ = self->priv->delete_pack_btn;
	_tmp21_ = self->priv->packs;
	_tmp21__length1 = self->priv->packs_length1;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp20_, _tmp21__length1 > 0);
	dc_sticker_manager_dialog_reload_stickers (self);
	_g_free0 (want);
	_g_free0 (_tmp0_);
}

static gchar*
dc_sticker_manager_dialog_selected_pack (DcStickerManagerDialog* self)
{
	guint sel = 0U;
	GtkDropDown* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	const gchar* _tmp3_ = NULL;
	gboolean _tmp4_ = FALSE;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gchar* _tmp9_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->pack_dropdown;
	_tmp1_ = gtk_drop_down_get_selected (_tmp0_);
	_tmp2_ = _tmp1_;
	sel = _tmp2_;
	_tmp5_ = self->priv->packs;
	_tmp5__length1 = self->priv->packs_length1;
	if (_tmp5__length1 > 0) {
		gchar** _tmp6_;
		gint _tmp6__length1;
		_tmp6_ = self->priv->packs;
		_tmp6__length1 = self->priv->packs_length1;
		_tmp4_ = sel < ((guint) _tmp6__length1);
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		gchar** _tmp7_;
		gint _tmp7__length1;
		const gchar* _tmp8_;
		_tmp7_ = self->priv->packs;
		_tmp7__length1 = self->priv->packs_length1;
		_tmp8_ = _tmp7_[sel];
		_tmp3_ = _tmp8_;
	} else {
		_tmp3_ = NULL;
	}
	_tmp9_ = g_strdup (_tmp3_);
	result = _tmp9_;
	return result;
}

static void
dc_sticker_manager_dialog_reload_stickers (DcStickerManagerDialog* self)
{
	GtkFlowBoxChild* child = NULL;
	gchar* pack = NULL;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	DcSticker** stickers = NULL;
	const gchar* _tmp10_;
	gint _tmp11_ = 0;
	DcSticker** _tmp12_;
	gint stickers_length1;
	gint _stickers_size_;
	GtkLabel* _tmp13_;
	GtkLabel* _tmp14_;
	DcSticker** _tmp15_;
	gint _tmp15__length1;
	DcSticker** _tmp16_;
	gint _tmp16__length1;
	g_return_if_fail (self != NULL);
	while (TRUE) {
		GtkFlowBox* _tmp0_;
		GtkFlowBoxChild* _tmp1_;
		GtkFlowBoxChild* _tmp2_;
		GtkFlowBoxChild* _tmp3_;
		GtkFlowBox* _tmp4_;
		GtkFlowBoxChild* _tmp5_;
		_tmp0_ = self->priv->sticker_grid;
		_tmp1_ = gtk_flow_box_get_child_at_index (_tmp0_, 0);
		_tmp2_ = _g_object_ref0 (_tmp1_);
		_g_object_unref0 (child);
		child = _tmp2_;
		_tmp3_ = child;
		if (!(_tmp3_ != NULL)) {
			break;
		}
		_tmp4_ = self->priv->sticker_grid;
		_tmp5_ = child;
		gtk_flow_box_remove (_tmp4_, (GtkWidget*) _tmp5_);
	}
	_tmp6_ = dc_sticker_manager_dialog_selected_pack (self);
	pack = _tmp6_;
	_tmp7_ = pack;
	if (_tmp7_ == NULL) {
		GtkLabel* _tmp8_;
		GtkLabel* _tmp9_;
		_tmp8_ = self->priv->placeholder;
		gtk_label_set_label (_tmp8_, "No sticker packs yet.\nPress + to create one.");
		_tmp9_ = self->priv->placeholder;
		gtk_widget_set_visible ((GtkWidget*) _tmp9_, TRUE);
		_g_free0 (pack);
		_g_object_unref0 (child);
		return;
	}
	_tmp10_ = pack;
	_tmp12_ = dc_sticker_store_list_stickers (_tmp10_, &_tmp11_);
	stickers = _tmp12_;
	stickers_length1 = _tmp11_;
	_stickers_size_ = stickers_length1;
	_tmp13_ = self->priv->placeholder;
	gtk_label_set_label (_tmp13_, "This pack has no stickers yet.\n" "Right-click a sticker in a conversation and choose " "\"Add Sticker…\".");
	_tmp14_ = self->priv->placeholder;
	_tmp15_ = stickers;
	_tmp15__length1 = stickers_length1;
	gtk_widget_set_visible ((GtkWidget*) _tmp14_, _tmp15__length1 == 0);
	_tmp16_ = stickers;
	_tmp16__length1 = stickers_length1;
	{
		DcSticker** sticker_collection = NULL;
		gint sticker_collection_length1 = 0;
		gint _sticker_collection_size_ = 0;
		gint sticker_it = 0;
		sticker_collection = _tmp16_;
		sticker_collection_length1 = _tmp16__length1;
		for (sticker_it = 0; sticker_it < sticker_collection_length1; sticker_it = sticker_it + 1) {
			DcSticker* _tmp17_;
			DcSticker* sticker = NULL;
			_tmp17_ = _g_object_ref0 (sticker_collection[sticker_it]);
			sticker = _tmp17_;
			{
				GtkFlowBox* _tmp18_;
				DcSticker* _tmp19_;
				GtkWidget* _tmp20_;
				GtkWidget* _tmp21_;
				_tmp18_ = self->priv->sticker_grid;
				_tmp19_ = sticker;
				_tmp20_ = dc_sticker_manager_dialog_build_sticker_card (self, _tmp19_);
				_tmp21_ = _tmp20_;
				gtk_flow_box_append (_tmp18_, _tmp21_);
				_g_object_unref0 (_tmp21_);
				_g_object_unref0 (sticker);
			}
		}
	}
	stickers = (_vala_array_free (stickers, stickers_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_free0 (pack);
	_g_object_unref0 (child);
}

static Block59Data*
block59_data_ref (Block59Data* _data59_)
{
	g_atomic_int_inc (&_data59_->_ref_count_);
	return _data59_;
}

static void
block59_data_unref (void * _userdata_)
{
	Block59Data* _data59_;
	_data59_ = (Block59Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data59_->_ref_count_)) {
		DcStickerManagerDialog* self;
		self = _data59_->self;
		_g_object_unref0 (_data59_->emoji_btn);
		_g_object_unref0 (_data59_->card);
		_g_object_unref0 (_data59_->sticker);
		_g_object_unref0 (self);
		g_slice_free (Block59Data, _data59_);
	}
}

static void
__lambda107_ (Block59Data* _data59_)
{
	DcStickerManagerDialog* self;
	GtkButton* _tmp0_;
	self = _data59_->self;
	_tmp0_ = _data59_->emoji_btn;
	dc_sticker_manager_dialog_pick_emoji (self, _data59_->sticker, _tmp0_);
}

static void
___lambda107__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda107_ (self);
}

static void
__lambda109_ (Block59Data* _data59_,
              gint n,
              gdouble x,
              gdouble y)
{
	DcStickerManagerDialog* self;
	GtkBox* _tmp0_;
	self = _data59_->self;
	_tmp0_ = _data59_->card;
	dc_sticker_manager_dialog_show_sticker_menu (self, _data59_->sticker, (GtkWidget*) _tmp0_, x, y);
}

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

static GtkWidget*
dc_sticker_manager_dialog_build_sticker_card (DcStickerManagerDialog* self,
                                              DcSticker* sticker)
{
	Block59Data* _data59_;
	DcSticker* _tmp0_;
	GtkBox* _tmp1_;
	GtkBox* _tmp2_;
	GtkWidget* thumb = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	DcWindow* _tmp6_;
	GtkWidget* _tmp7_;
	GtkWidget* _tmp8_;
	GtkWidget* _tmp9_;
	GtkWidget* _tmp10_;
	GtkWidget* _tmp11_;
	GtkWidget* _tmp12_;
	GtkBox* _tmp13_;
	GtkWidget* _tmp14_;
	GtkButton* _tmp15_;
	GtkButton* _tmp16_;
	GtkButton* _tmp17_;
	GtkButton* _tmp18_;
	GtkButton* _tmp19_;
	const gchar* _tmp20_;
	gint _tmp21_;
	gint _tmp22_;
	GtkButton* _tmp26_;
	GtkBox* _tmp27_;
	GtkButton* _tmp28_;
	GtkGestureClick* click = NULL;
	GtkGestureClick* _tmp29_;
	GtkBox* _tmp30_;
	GtkEventController* _tmp31_;
	GtkBox* _tmp32_;
	GtkWidget* _tmp33_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (sticker != NULL, NULL);
	_data59_ = g_slice_new0 (Block59Data);
	_data59_->_ref_count_ = 1;
	_data59_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (sticker);
	_g_object_unref0 (_data59_->sticker);
	_data59_->sticker = _tmp0_;
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	g_object_ref_sink (_tmp1_);
	_data59_->card = _tmp1_;
	_tmp2_ = _data59_->card;
	gtk_widget_add_css_class ((GtkWidget*) _tmp2_, "card");
	_tmp3_ = _data59_->sticker->file_name;
	_tmp4_ = dc_sticker_store_sticker_path (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->priv->app_window;
	_tmp7_ = dc_sticker_thumbnail (_tmp5_, MAX (1, gtk_widget_get_scale_factor ((GtkWidget*) _tmp6_)), DC_STICKER_MANAGER_DIALOG_THUMB_SIZE);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp5_);
	thumb = _tmp8_;
	_tmp9_ = thumb;
	gtk_widget_set_halign (_tmp9_, GTK_ALIGN_CENTER);
	_tmp10_ = thumb;
	gtk_widget_set_margin_top (_tmp10_, 8);
	_tmp11_ = thumb;
	gtk_widget_set_margin_start (_tmp11_, 8);
	_tmp12_ = thumb;
	gtk_widget_set_margin_end (_tmp12_, 8);
	_tmp13_ = _data59_->card;
	_tmp14_ = thumb;
	gtk_box_append (_tmp13_, _tmp14_);
	_tmp15_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp15_);
	_data59_->emoji_btn = _tmp15_;
	_tmp16_ = _data59_->emoji_btn;
	gtk_widget_set_halign ((GtkWidget*) _tmp16_, GTK_ALIGN_CENTER);
	_tmp17_ = _data59_->emoji_btn;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp17_, 6);
	_tmp18_ = _data59_->emoji_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp18_, "flat");
	_tmp19_ = _data59_->emoji_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp19_, "Emoji associated with this sticker");
	_tmp20_ = _data59_->sticker->emoji;
	_tmp21_ = strlen (_tmp20_);
	_tmp22_ = _tmp21_;
	if (_tmp22_ > 0) {
		GtkButton* _tmp23_;
		const gchar* _tmp24_;
		_tmp23_ = _data59_->emoji_btn;
		_tmp24_ = _data59_->sticker->emoji;
		gtk_button_set_label (_tmp23_, _tmp24_);
	} else {
		GtkButton* _tmp25_;
		_tmp25_ = _data59_->emoji_btn;
		gtk_button_set_icon_name (_tmp25_, "face-smile-symbolic");
	}
	_tmp26_ = _data59_->emoji_btn;
	g_signal_connect_data (_tmp26_, "clicked", (GCallback) ___lambda107__gtk_button_clicked, block59_data_ref (_data59_), (GClosureNotify) block59_data_unref, 0);
	_tmp27_ = _data59_->card;
	_tmp28_ = _data59_->emoji_btn;
	gtk_box_append (_tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = (GtkGestureClick*) gtk_gesture_click_new ();
	click = _tmp29_;
	gtk_gesture_single_set_button ((GtkGestureSingle*) click, (guint) GDK_BUTTON_SECONDARY);
	g_signal_connect_data (click, "pressed", (GCallback) ___lambda109__gtk_gesture_click_pressed, block59_data_ref (_data59_), (GClosureNotify) block59_data_unref, 0);
	_tmp30_ = _data59_->card;
	_tmp31_ = _g_object_ref0 ((GtkEventController*) click);
	gtk_widget_add_controller ((GtkWidget*) _tmp30_, _tmp31_);
	_tmp32_ = _data59_->card;
	_tmp33_ = _g_object_ref0 ((GtkWidget*) _tmp32_);
	result = _tmp33_;
	_g_object_unref0 (click);
	_g_object_unref0 (thumb);
	block59_data_unref (_data59_);
	_data59_ = NULL;
	return result;
}

static Block60Data*
block60_data_ref (Block60Data* _data60_)
{
	g_atomic_int_inc (&_data60_->_ref_count_);
	return _data60_;
}

static void
block60_data_unref (void * _userdata_)
{
	Block60Data* _data60_;
	_data60_ = (Block60Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data60_->_ref_count_)) {
		DcStickerManagerDialog* self;
		self = _data60_->self;
		_g_object_unref0 (_data60_->sticker);
		_g_object_unref0 (_data60_->btn);
		_g_object_unref0 (self);
		g_slice_free (Block60Data, _data60_);
	}
}

static void
__lambda108_ (Block60Data* _data60_,
              const gchar* emoji)
{
	DcStickerManagerDialog* self;
	GError* _inner_error0_ = NULL;
	self = _data60_->self;
	g_return_if_fail (emoji != NULL);
	{
		dc_sticker_store_set_emoji (_data60_->sticker, emoji, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		gtk_button_set_label (_data60_->btn, emoji);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = e;
		_tmp1_ = _tmp0_->message;
		_tmp2_ = g_strconcat ("Could not set emoji: ", _tmp1_, NULL);
		_tmp3_ = _tmp2_;
		dc_show_error ((GtkWidget*) self, _tmp3_);
		_g_free0 (_tmp3_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda108__gtk_emoji_chooser_emoji_picked (GtkEmojiChooser* _sender,
                                              const gchar* text,
                                              gpointer self)
{
	__lambda108_ (self, text);
}

static void
dc_sticker_manager_dialog_pick_emoji (DcStickerManagerDialog* self,
                                      DcSticker* sticker,
                                      GtkButton* btn)
{
	Block60Data* _data60_;
	DcSticker* _tmp0_;
	GtkButton* _tmp1_;
	GtkEmojiChooser* chooser = NULL;
	GtkEmojiChooser* _tmp2_;
	GtkEmojiChooser* _tmp3_;
	GtkEmojiChooser* _tmp5_;
	GtkEmojiChooser* _tmp6_;
	GtkEmojiChooser* _tmp7_;
	GtkEmojiChooser* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (sticker != NULL);
	g_return_if_fail (btn != NULL);
	_data60_ = g_slice_new0 (Block60Data);
	_data60_->_ref_count_ = 1;
	_data60_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (sticker);
	_g_object_unref0 (_data60_->sticker);
	_data60_->sticker = _tmp0_;
	_tmp1_ = _g_object_ref0 (btn);
	_g_object_unref0 (_data60_->btn);
	_data60_->btn = _tmp1_;
	_tmp2_ = dc_create_emoji_chooser ();
	chooser = _tmp2_;
	_tmp3_ = chooser;
	if (_tmp3_ == NULL) {
		DcWindow* _tmp4_;
		_tmp4_ = self->priv->app_window;
		dc_window_show_toast (_tmp4_, "Emoji picker unavailable");
		_g_object_unref0 (chooser);
		block60_data_unref (_data60_);
		_data60_ = NULL;
		return;
	}
	_tmp5_ = chooser;
	g_signal_connect_data (_tmp5_, "emoji-picked", (GCallback) ___lambda108__gtk_emoji_chooser_emoji_picked, block60_data_ref (_data60_), (GClosureNotify) block60_data_unref, 0);
	_tmp6_ = chooser;
	gtk_widget_set_parent ((GtkWidget*) _tmp6_, (GtkWidget*) _data60_->btn);
	_tmp7_ = chooser;
	dc_unparent_on_close ((GtkPopover*) _tmp7_);
	_tmp8_ = chooser;
	gtk_popover_popup ((GtkPopover*) _tmp8_);
	_g_object_unref0 (chooser);
	block60_data_unref (_data60_);
	_data60_ = NULL;
}

static Block61Data*
block61_data_ref (Block61Data* _data61_)
{
	g_atomic_int_inc (&_data61_->_ref_count_);
	return _data61_;
}

static void
block61_data_unref (void * _userdata_)
{
	Block61Data* _data61_;
	_data61_ = (Block61Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data61_->_ref_count_)) {
		DcStickerManagerDialog* self;
		self = _data61_->self;
		_g_object_unref0 (_data61_->sticker);
		_g_object_unref0 (self);
		g_slice_free (Block61Data, _data61_);
	}
}

static void
__lambda110_ (Block61Data* _data61_)
{
	DcStickerManagerDialog* self;
	GdkClipboard* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	DcWindow* _tmp4_;
	self = _data61_->self;
	_tmp0_ = gtk_widget_get_clipboard ((GtkWidget*) self);
	_tmp1_ = _data61_->sticker->file_name;
	_tmp2_ = dc_sticker_store_sticker_path (_tmp1_);
	_tmp3_ = _tmp2_;
	gdk_clipboard_set_text (_tmp0_, _tmp3_);
	_g_free0 (_tmp3_);
	_tmp4_ = self->priv->app_window;
	dc_window_show_toast (_tmp4_, "File path copied");
}

static void
___lambda110__dc_popover_button_selected (DcPopoverButton* _sender,
                                          gpointer self)
{
	__lambda110_ (self);
}

static Block62Data*
block62_data_ref (Block62Data* _data62_)
{
	g_atomic_int_inc (&_data62_->_ref_count_);
	return _data62_;
}

static void
block62_data_unref (void * _userdata_)
{
	Block62Data* _data62_;
	_data62_ = (Block62Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data62_->_ref_count_)) {
		DcStickerManagerDialog* self;
		self = _data62_->_data61_->self;
		_g_free0 (_data62_->dest);
		block61_data_unref (_data62_->_data61_);
		_data62_->_data61_ = NULL;
		g_slice_free (Block62Data, _data62_);
	}
}

static void
____lambda111_ (Block62Data* _data62_)
{
	Block61Data* _data61_;
	DcStickerManagerDialog* self;
	GError* _inner_error0_ = NULL;
	_data61_ = _data62_->_data61_;
	self = _data61_->self;
	{
		gchar* _tmp0_ = NULL;
		gboolean _tmp1_ = FALSE;
		const gchar* _tmp2_;
		DcWindow* _tmp7_;
		_tmp2_ = _data62_->dest;
		_tmp1_ = dc_sticker_store_move_sticker (_data61_->sticker, _tmp2_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (_tmp0_);
			goto __catch0_g_error;
		}
		if (_tmp1_) {
			const gchar* _tmp3_;
			gchar* _tmp4_;
			_tmp3_ = _data62_->dest;
			_tmp4_ = g_strdup_printf ("Sticker moved to \"%s\"", _tmp3_);
			_g_free0 (_tmp0_);
			_tmp0_ = _tmp4_;
		} else {
			const gchar* _tmp5_;
			gchar* _tmp6_;
			_tmp5_ = _data62_->dest;
			_tmp6_ = g_strdup_printf ("Sticker is already in \"%s\"", _tmp5_);
			_g_free0 (_tmp0_);
			_tmp0_ = _tmp6_;
		}
		_tmp7_ = self->priv->app_window;
		dc_window_show_toast (_tmp7_, _tmp0_);
		_g_free0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp8_ = e;
		_tmp9_ = _tmp8_->message;
		_tmp10_ = g_strconcat ("Could not move sticker: ", _tmp9_, NULL);
		_tmp11_ = _tmp10_;
		dc_show_error ((GtkWidget*) self, _tmp11_);
		_g_free0 (_tmp11_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	dc_sticker_manager_dialog_reload_stickers (self);
}

static void
_____lambda111__dc_popover_button_selected (DcPopoverButton* _sender,
                                            gpointer self)
{
	____lambda111_ (self);
}

static void
__lambda112_ (Block61Data* _data61_)
{
	DcStickerManagerDialog* self;
	self = _data61_->self;
	dc_sticker_manager_dialog_confirm_delete_sticker (self, _data61_->sticker, NULL, NULL);
}

static void
___lambda112__dc_popover_button_selected (DcPopoverButton* _sender,
                                          gpointer self)
{
	__lambda112_ (self);
}

static void
dc_sticker_manager_dialog_show_sticker_menu (DcStickerManagerDialog* self,
                                             DcSticker* sticker,
                                             GtkWidget* parent,
                                             gdouble x,
                                             gdouble y)
{
	Block61Data* _data61_;
	DcSticker* _tmp0_;
	GtkBox* vbox = NULL;
	GtkPopover* popover = NULL;
	GtkBox* _tmp1_ = NULL;
	GtkPopover* _tmp2_;
	DcPopoverButton* copy_btn = NULL;
	GtkPopover* _tmp3_;
	DcPopoverButton* _tmp4_;
	DcPopoverButton* _tmp5_;
	GtkBox* _tmp6_;
	DcPopoverButton* _tmp7_;
	GtkBox* _tmp8_;
	GtkSeparator* _tmp9_;
	GtkSeparator* _tmp10_;
	gboolean has_move_targets = FALSE;
	gchar** _tmp11_;
	gint _tmp11__length1;
	DcPopoverButton* delete_btn = NULL;
	GtkPopover* _tmp29_;
	DcPopoverButton* _tmp30_;
	GtkBox* _tmp31_;
	GtkPopover* _tmp32_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (sticker != NULL);
	g_return_if_fail (parent != NULL);
	_data61_ = g_slice_new0 (Block61Data);
	_data61_->_ref_count_ = 1;
	_data61_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (sticker);
	_g_object_unref0 (_data61_->sticker);
	_data61_->sticker = _tmp0_;
	_tmp2_ = dc_popover_menu (parent, x, y, &_tmp1_);
	_g_object_unref0 (vbox);
	vbox = _tmp1_;
	popover = _tmp2_;
	_tmp3_ = popover;
	_tmp4_ = dc_popover_button_new (_tmp3_, "Copy File Path", FALSE, FALSE);
	g_object_ref_sink (_tmp4_);
	copy_btn = _tmp4_;
	_tmp5_ = copy_btn;
	g_signal_connect_data (_tmp5_, "selected", (GCallback) ___lambda110__dc_popover_button_selected, block61_data_ref (_data61_), (GClosureNotify) block61_data_unref, 0);
	_tmp6_ = vbox;
	_tmp7_ = copy_btn;
	gtk_box_append (_tmp6_, (GtkWidget*) _tmp7_);
	_tmp8_ = vbox;
	_tmp9_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp9_);
	_tmp10_ = _tmp9_;
	gtk_box_append (_tmp8_, (GtkWidget*) _tmp10_);
	_g_object_unref0 (_tmp10_);
	has_move_targets = FALSE;
	_tmp11_ = self->priv->packs;
	_tmp11__length1 = self->priv->packs_length1;
	{
		gchar** other_collection = NULL;
		gint other_collection_length1 = 0;
		gint _other_collection_size_ = 0;
		gint other_it = 0;
		other_collection = _tmp11_;
		other_collection_length1 = _tmp11__length1;
		for (other_it = 0; other_it < other_collection_length1; other_it = other_it + 1) {
			gchar* _tmp12_;
			gchar* other = NULL;
			_tmp12_ = g_strdup (other_collection[other_it]);
			other = _tmp12_;
			{
				Block62Data* _data62_;
				const gchar* _tmp13_;
				const gchar* _tmp14_;
				const gchar* _tmp15_;
				gchar* _tmp16_;
				DcPopoverButton* move_btn = NULL;
				GtkPopover* _tmp17_;
				const gchar* _tmp18_;
				gchar* _tmp19_;
				gchar* _tmp20_;
				DcPopoverButton* _tmp21_;
				DcPopoverButton* _tmp22_;
				DcPopoverButton* _tmp23_;
				GtkBox* _tmp24_;
				DcPopoverButton* _tmp25_;
				_data62_ = g_slice_new0 (Block62Data);
				_data62_->_ref_count_ = 1;
				_data62_->_data61_ = block61_data_ref (_data61_);
				_tmp13_ = other;
				_tmp14_ = _data61_->sticker->pack;
				if (g_strcmp0 (_tmp13_, _tmp14_) == 0) {
					_g_free0 (other);
					block62_data_unref (_data62_);
					_data62_ = NULL;
					continue;
				}
				has_move_targets = TRUE;
				_tmp15_ = other;
				_tmp16_ = g_strdup (_tmp15_);
				_data62_->dest = _tmp16_;
				_tmp17_ = popover;
				_tmp18_ = _data62_->dest;
				_tmp19_ = g_strdup_printf ("Move to \"%s\"", _tmp18_);
				_tmp20_ = _tmp19_;
				_tmp21_ = dc_popover_button_new (_tmp17_, _tmp20_, FALSE, FALSE);
				g_object_ref_sink (_tmp21_);
				_tmp22_ = _tmp21_;
				_g_free0 (_tmp20_);
				move_btn = _tmp22_;
				_tmp23_ = move_btn;
				g_signal_connect_data (_tmp23_, "selected", (GCallback) _____lambda111__dc_popover_button_selected, block62_data_ref (_data62_), (GClosureNotify) block62_data_unref, 0);
				_tmp24_ = vbox;
				_tmp25_ = move_btn;
				gtk_box_append (_tmp24_, (GtkWidget*) _tmp25_);
				_g_object_unref0 (move_btn);
				_g_free0 (other);
				block62_data_unref (_data62_);
				_data62_ = NULL;
			}
		}
	}
	if (has_move_targets) {
		GtkBox* _tmp26_;
		GtkSeparator* _tmp27_;
		GtkSeparator* _tmp28_;
		_tmp26_ = vbox;
		_tmp27_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
		g_object_ref_sink (_tmp27_);
		_tmp28_ = _tmp27_;
		gtk_box_append (_tmp26_, (GtkWidget*) _tmp28_);
		_g_object_unref0 (_tmp28_);
	}
	_tmp29_ = popover;
	_tmp30_ = dc_popover_button_new (_tmp29_, "Delete…", TRUE, FALSE);
	g_object_ref_sink (_tmp30_);
	delete_btn = _tmp30_;
	g_signal_connect_data (delete_btn, "selected", (GCallback) ___lambda112__dc_popover_button_selected, block61_data_ref (_data61_), (GClosureNotify) block61_data_unref, 0);
	_tmp31_ = vbox;
	gtk_box_append (_tmp31_, (GtkWidget*) delete_btn);
	_tmp32_ = popover;
	gtk_popover_popup (_tmp32_);
	_g_object_unref0 (delete_btn);
	_g_object_unref0 (copy_btn);
	_g_object_unref0 (popover);
	_g_object_unref0 (vbox);
	block61_data_unref (_data61_);
	_data61_ = NULL;
}

static void
dc_sticker_manager_dialog_confirm_delete_sticker_data_free (gpointer _data)
{
	DcStickerManagerDialogConfirmDeleteStickerData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->sticker);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcStickerManagerDialogConfirmDeleteStickerData, _data_);
}

static void
dc_sticker_manager_dialog_confirm_delete_sticker (DcStickerManagerDialog* self,
                                                  DcSticker* sticker,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	DcStickerManagerDialogConfirmDeleteStickerData* _data_;
	DcStickerManagerDialog* _tmp0_;
	DcSticker* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (sticker != NULL);
	_data_ = g_slice_new0 (DcStickerManagerDialogConfirmDeleteStickerData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_sticker_manager_dialog_confirm_delete_sticker_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (sticker);
	_g_object_unref0 (_data_->sticker);
	_data_->sticker = _tmp1_;
	dc_sticker_manager_dialog_confirm_delete_sticker_co (_data_);
}

static void
dc_sticker_manager_dialog_confirm_delete_sticker_finish (DcStickerManagerDialog* self,
                                                         GAsyncResult* _res_)
{
	DcStickerManagerDialogConfirmDeleteStickerData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_sticker_manager_dialog_confirm_delete_sticker_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_)
{
	DcStickerManagerDialogConfirmDeleteStickerData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_sticker_manager_dialog_confirm_delete_sticker_co (_data_);
}

static gboolean
dc_sticker_manager_dialog_confirm_delete_sticker_co (DcStickerManagerDialogConfirmDeleteStickerData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->sticker->pack;
	_data_->_tmp1_ = g_strdup_printf ("Delete this sticker from \"%s\"? This cannot be undone.", _data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_state_ = 1;
	dc_confirm_action ((GtkWidget*) _data_->self, "Delete Sticker?", _data_->_tmp2_, "delete", "Delete", dc_sticker_manager_dialog_confirm_delete_sticker_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp3_ = dc_confirm_action_finish (_data_->_res_);
	_g_free0 (_data_->_tmp2_);
	if (_data_->_tmp3_) {
		dc_sticker_store_delete_sticker (_data_->sticker);
		dc_sticker_manager_dialog_reload_stickers (_data_->self);
	}
	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 Block63Data*
block63_data_ref (Block63Data* _data63_)
{
	g_atomic_int_inc (&_data63_->_ref_count_);
	return _data63_;
}

static void
block63_data_unref (void * _userdata_)
{
	Block63Data* _data63_;
	_data63_ = (Block63Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data63_->_ref_count_)) {
		DcStickerManagerDialog* self;
		self = _data63_->self;
		_g_object_unref0 (_data63_->entry);
		_g_free0 (_data63_->pack);
		_g_object_unref0 (self);
		g_slice_free (Block63Data, _data63_);
	}
}

static void
_vala_array_add46 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
__lambda114_ (Block63Data* _data63_,
              const gchar* r)
{
	DcStickerManagerDialog* self;
	gchar* new_pack = NULL;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_ = FALSE;
	const gchar* _tmp5_;
	gchar** updated = NULL;
	gchar** _tmp14_;
	gint updated_length1;
	gint _updated_size_;
	gchar** _tmp15_;
	gint _tmp15__length1;
	gchar** _tmp29_;
	gint _tmp29__length1;
	const gchar* _tmp30_;
	GError* _inner_error0_ = NULL;
	self = _data63_->self;
	g_return_if_fail (r != NULL);
	if (g_strcmp0 (r, "rename") != 0) {
		return;
	}
	_tmp0_ = _data63_->entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = dc_sticker_store_sanitize_pack_name (_tmp2_);
	new_pack = _tmp3_;
	_tmp5_ = new_pack;
	if (_tmp5_ == NULL) {
		_tmp4_ = TRUE;
	} else {
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		_tmp6_ = new_pack;
		_tmp7_ = _data63_->pack;
		_tmp4_ = g_strcmp0 (_tmp6_, _tmp7_) == 0;
	}
	if (_tmp4_) {
		_g_free0 (new_pack);
		return;
	}
	{
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		_tmp8_ = _data63_->pack;
		_tmp9_ = new_pack;
		dc_sticker_store_rename_pack (_tmp8_, _tmp9_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp10_;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp10_ = e;
		_tmp11_ = _tmp10_->message;
		_tmp12_ = g_strconcat ("Could not rename pack: ", _tmp11_, NULL);
		_tmp13_ = _tmp12_;
		dc_show_error ((GtkWidget*) self, _tmp13_);
		_g_free0 (_tmp13_);
		_g_error_free0 (e);
		_g_free0 (new_pack);
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (new_pack);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp14_ = g_new0 (gchar*, 0 + 1);
	updated = _tmp14_;
	updated_length1 = 0;
	_updated_size_ = updated_length1;
	_tmp15_ = self->priv->packs;
	_tmp15__length1 = self->priv->packs_length1;
	{
		gchar** existing_collection = NULL;
		gint existing_collection_length1 = 0;
		gint _existing_collection_size_ = 0;
		gint existing_it = 0;
		existing_collection = _tmp15_;
		existing_collection_length1 = _tmp15__length1;
		for (existing_it = 0; existing_it < existing_collection_length1; existing_it = existing_it + 1) {
			gchar* _tmp16_;
			gchar* existing = NULL;
			_tmp16_ = g_strdup (existing_collection[existing_it]);
			existing = _tmp16_;
			{
				const gchar* _tmp17_ = NULL;
				const gchar* _tmp18_;
				const gchar* _tmp19_;
				gchar* name = NULL;
				gchar* _tmp22_;
				gboolean seen = FALSE;
				gchar** _tmp23_;
				gint _tmp23__length1;
				_tmp18_ = existing;
				_tmp19_ = _data63_->pack;
				if (g_strcmp0 (_tmp18_, _tmp19_) == 0) {
					const gchar* _tmp20_;
					_tmp20_ = new_pack;
					_tmp17_ = _tmp20_;
				} else {
					const gchar* _tmp21_;
					_tmp21_ = existing;
					_tmp17_ = _tmp21_;
				}
				_tmp22_ = g_strdup (_tmp17_);
				name = _tmp22_;
				seen = FALSE;
				_tmp23_ = updated;
				_tmp23__length1 = updated_length1;
				{
					gchar** prev_collection = NULL;
					gint prev_collection_length1 = 0;
					gint _prev_collection_size_ = 0;
					gint prev_it = 0;
					prev_collection = _tmp23_;
					prev_collection_length1 = _tmp23__length1;
					for (prev_it = 0; prev_it < prev_collection_length1; prev_it = prev_it + 1) {
						gchar* _tmp24_;
						gchar* prev = NULL;
						_tmp24_ = g_strdup (prev_collection[prev_it]);
						prev = _tmp24_;
						{
							const gchar* _tmp25_;
							const gchar* _tmp26_;
							_tmp25_ = prev;
							_tmp26_ = name;
							if (g_strcmp0 (_tmp25_, _tmp26_) == 0) {
								seen = TRUE;
							}
							_g_free0 (prev);
						}
					}
				}
				if (!seen) {
					const gchar* _tmp27_;
					gchar* _tmp28_;
					_tmp27_ = name;
					_tmp28_ = g_strdup (_tmp27_);
					_vala_array_add46 (&updated, &updated_length1, &_updated_size_, _tmp28_);
				}
				_g_free0 (name);
				_g_free0 (existing);
			}
		}
	}
	_tmp29_ = updated;
	_tmp29__length1 = updated_length1;
	_tmp30_ = new_pack;
	dc_sticker_manager_dialog_show_packs (self, _tmp29_, (gint) _tmp29__length1, _tmp30_);
	updated = (_vala_array_free (updated, updated_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (new_pack);
}

static void
___lambda114__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                         const gchar* response,
                                         gpointer self)
{
	__lambda114_ (self, response);
}

static void
dc_sticker_manager_dialog_on_rename_pack (DcStickerManagerDialog* self)
{
	Block63Data* _data63_;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	AdwAlertDialog* d = NULL;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	AdwAlertDialog* _tmp5_;
	AdwAlertDialog* _tmp6_;
	AdwAlertDialog* _tmp7_;
	AdwAlertDialog* _tmp8_;
	AdwAlertDialog* _tmp9_;
	AdwAlertDialog* _tmp10_;
	AdwAlertDialog* _tmp11_;
	GtkEntry* _tmp12_;
	GtkEntry* _tmp13_;
	const gchar* _tmp14_;
	GtkEntry* _tmp15_;
	AdwAlertDialog* _tmp16_;
	GtkEntry* _tmp17_;
	AdwAlertDialog* _tmp18_;
	AdwAlertDialog* _tmp19_;
	g_return_if_fail (self != NULL);
	_data63_ = g_slice_new0 (Block63Data);
	_data63_->_ref_count_ = 1;
	_data63_->self = g_object_ref (self);
	_tmp0_ = dc_sticker_manager_dialog_selected_pack (self);
	_data63_->pack = _tmp0_;
	_tmp1_ = _data63_->pack;
	if (_tmp1_ == NULL) {
		block63_data_unref (_data63_);
		_data63_ = NULL;
		return;
	}
	_tmp2_ = _data63_->pack;
	_tmp3_ = g_strdup_printf ("New name for the pack \"%s\".", _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = (AdwAlertDialog*) adw_alert_dialog_new ("Rename Sticker Pack", _tmp4_);
	g_object_ref_sink (_tmp5_);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	d = _tmp6_;
	_tmp7_ = d;
	adw_alert_dialog_add_response (_tmp7_, "cancel", "Cancel");
	_tmp8_ = d;
	adw_alert_dialog_add_response (_tmp8_, "rename", "Rename");
	_tmp9_ = d;
	adw_alert_dialog_set_response_appearance (_tmp9_, "rename", ADW_RESPONSE_SUGGESTED);
	_tmp10_ = d;
	adw_alert_dialog_set_default_response (_tmp10_, "rename");
	_tmp11_ = d;
	adw_alert_dialog_set_close_response (_tmp11_, "cancel");
	_tmp12_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp12_);
	_data63_->entry = _tmp12_;
	_tmp13_ = _data63_->entry;
	_tmp14_ = _data63_->pack;
	gtk_editable_set_text ((GtkEditable*) _tmp13_, _tmp14_);
	_tmp15_ = _data63_->entry;
	gtk_entry_set_activates_default (_tmp15_, TRUE);
	_tmp16_ = d;
	_tmp17_ = _data63_->entry;
	adw_alert_dialog_set_extra_child (_tmp16_, (GtkWidget*) _tmp17_);
	_tmp18_ = d;
	g_signal_connect_data (_tmp18_, "response", (GCallback) ___lambda114__adw_alert_dialog_response, block63_data_ref (_data63_), (GClosureNotify) block63_data_unref, 0);
	_tmp19_ = d;
	adw_dialog_present ((AdwDialog*) _tmp19_, (GtkWidget*) self);
	_g_object_unref0 (d);
	block63_data_unref (_data63_);
	_data63_ = NULL;
}

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

static void
dc_sticker_manager_dialog_on_delete_pack (DcStickerManagerDialog* self,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	DcStickerManagerDialogOnDeletePackData* _data_;
	DcStickerManagerDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcStickerManagerDialogOnDeletePackData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_sticker_manager_dialog_on_delete_pack_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_sticker_manager_dialog_on_delete_pack_co (_data_);
}

static void
dc_sticker_manager_dialog_on_delete_pack_finish (DcStickerManagerDialog* self,
                                                 GAsyncResult* _res_)
{
	DcStickerManagerDialogOnDeletePackData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_sticker_manager_dialog_on_delete_pack_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_)
{
	DcStickerManagerDialogOnDeletePackData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_sticker_manager_dialog_on_delete_pack_co (_data_);
}

static gboolean
dc_sticker_manager_dialog_on_delete_pack_co (DcStickerManagerDialogOnDeletePackData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = dc_sticker_manager_dialog_selected_pack (_data_->self);
	_data_->pack = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->pack;
	if (_data_->_tmp1_ == NULL) {
		_g_free0 (_data_->pack);
		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_->_tmp2_ = _data_->pack;
	_data_->_tmp3_ = g_strdup_printf ("Delete the pack \"%s\" and all of its stickers? This cannot be undone.", _data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_state_ = 1;
	dc_confirm_action ((GtkWidget*) _data_->self, "Delete Sticker Pack?", _data_->_tmp4_, "delete", "Delete Pack", dc_sticker_manager_dialog_on_delete_pack_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp5_ = dc_confirm_action_finish (_data_->_res_);
	_g_free0 (_data_->_tmp4_);
	if (_data_->_tmp5_) {
		_data_->_tmp6_ = _data_->pack;
		dc_sticker_store_delete_pack (_data_->_tmp6_);
		dc_sticker_manager_dialog_reload_packs (_data_->self, NULL);
	}
	_g_free0 (_data_->pack);
	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_sticker_manager_dialog_class_init (DcStickerManagerDialogClass * klass,
                                      gpointer klass_data)
{
	dc_sticker_manager_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcStickerManagerDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_sticker_manager_dialog_finalize;
}

static void
dc_sticker_manager_dialog_instance_init (DcStickerManagerDialog * self,
                                         gpointer klass)
{
	gchar** _tmp0_;
	self->priv = dc_sticker_manager_dialog_get_instance_private (self);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	self->priv->packs = _tmp0_;
	self->priv->packs_length1 = 0;
	self->priv->_packs_size_ = self->priv->packs_length1;
	self->priv->syncing_packs = FALSE;
}

static void
dc_sticker_manager_dialog_finalize (GObject * obj)
{
	DcStickerManagerDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_STICKER_MANAGER_DIALOG, DcStickerManagerDialog);
	_g_object_unref0 (self->priv->pack_dropdown);
	_g_object_unref0 (self->priv->sticker_grid);
	_g_object_unref0 (self->priv->placeholder);
	_g_object_unref0 (self->priv->rename_pack_btn);
	_g_object_unref0 (self->priv->delete_pack_btn);
	self->priv->packs = (_vala_array_free (self->priv->packs, self->priv->packs_length1, (GDestroyNotify) g_free), NULL);
	G_OBJECT_CLASS (dc_sticker_manager_dialog_parent_class)->finalize (obj);
}

/**
     * Dialog to manage local sticker packs: a pack selector with a [+]
     * button to create packs, the pack's stickers with their associated
     * emoji, and a destructive button to delete the whole pack. Stickers
     * are added from the message context menu ("Add Sticker…").
     */
static GType
dc_sticker_manager_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcStickerManagerDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_sticker_manager_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcStickerManagerDialog), 0, (GInstanceInitFunc) dc_sticker_manager_dialog_instance_init, NULL };
	GType dc_sticker_manager_dialog_type_id;
	dc_sticker_manager_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcStickerManagerDialog", &g_define_type_info, 0);
	DcStickerManagerDialog_private_offset = g_type_add_instance_private (dc_sticker_manager_dialog_type_id, sizeof (DcStickerManagerDialogPrivate));
	return dc_sticker_manager_dialog_type_id;
}

GType
dc_sticker_manager_dialog_get_type (void)
{
	static volatile gsize dc_sticker_manager_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_sticker_manager_dialog_type_id__once)) {
		GType dc_sticker_manager_dialog_type_id;
		dc_sticker_manager_dialog_type_id = dc_sticker_manager_dialog_get_type_once ();
		g_once_init_leave (&dc_sticker_manager_dialog_type_id__once, dc_sticker_manager_dialog_type_id);
	}
	return dc_sticker_manager_dialog_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

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

