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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib-object.h>

#define DC_STICKER_PICKER_THUMB_SIZE 64
#define DC_STICKER_PICKER_COLUMNS 4
#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 _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define DC_TYPE_STICKER_PICKER (dc_sticker_picker_get_type ())
#define DC_STICKER_PICKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_STICKER_PICKER, DcStickerPicker))
#define DC_STICKER_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_STICKER_PICKER, DcStickerPickerClass))
#define DC_IS_STICKER_PICKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_STICKER_PICKER))
#define DC_IS_STICKER_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_STICKER_PICKER))
#define DC_STICKER_PICKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_STICKER_PICKER, DcStickerPickerClass))

typedef struct _DcStickerPicker DcStickerPicker;
typedef struct _DcStickerPickerClass DcStickerPickerClass;
typedef struct _DcStickerPickerPrivate DcStickerPickerPrivate;

#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;
enum  {
	DC_STICKER_PICKER_0_PROPERTY,
	DC_STICKER_PICKER_NUM_PROPERTIES
};
static GParamSpec* dc_sticker_picker_properties[DC_STICKER_PICKER_NUM_PROPERTIES];
typedef struct _Block64Data Block64Data;
typedef struct _DcStickerPrivate DcStickerPrivate;
typedef struct _Block65Data Block65Data;
typedef struct _Block66Data Block66Data;
enum  {
	DC_STICKER_PICKER_STICKER_PICKED_SIGNAL,
	DC_STICKER_PICKER_NUM_SIGNALS
};
static guint dc_sticker_picker_signals[DC_STICKER_PICKER_NUM_SIGNALS] = {0};

struct _DcStickerPicker {
	GtkPopover parent_instance;
	DcStickerPickerPrivate * priv;
};

struct _DcStickerPickerClass {
	GtkPopoverClass parent_class;
};

struct _DcStickerPickerPrivate {
	GtkBox* sections;
	GtkLabel* placeholder;
	GtkBox* filter_bar;
	GtkBox* footer;
	gchar* filter_emoji;
	DcSticker** stickers;
	gint stickers_length1;
	gint _stickers_size_;
};

struct _Block64Data {
	int _ref_count_;
	DcStickerPicker* self;
	GtkToggleButton* all_btn;
};

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

struct _DcStickerClass {
	GObjectClass parent_class;
};

struct _Block65Data {
	int _ref_count_;
	Block64Data * _data64_;
	GtkToggleButton* btn;
	gchar* wanted;
};

struct _Block66Data {
	int _ref_count_;
	DcStickerPicker* self;
	DcSticker* sticker;
};

static gint DcStickerPicker_private_offset;
static gpointer dc_sticker_picker_parent_class = NULL;

VALA_EXTERN GtkWidget* dc_sticker_thumbnail (const gchar* path,
                                 gint scale_factor,
                                 gint size);
VALA_EXTERN GtkPicture* dc_sticker_thumb_picture (GdkPaintable* paintable,
                                      gint size);
VALA_EXTERN GdkPixbuf* dc_scaled_frame_from_file (const gchar* path,
                                      gint max_px,
                                      GError** error);
VALA_EXTERN GdkTexture* dc_texture_from_pixbuf (GdkPixbuf* pixbuf);
VALA_EXTERN GType dc_sticker_picker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcStickerPicker, g_object_unref)
VALA_EXTERN GType dc_sticker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSticker, g_object_unref)
VALA_EXTERN DcStickerPicker* dc_sticker_picker_new (void);
VALA_EXTERN DcStickerPicker* dc_sticker_picker_construct (GType object_type);
static void __lambda28_ (DcStickerPicker* self);
static void dc_sticker_picker_reload (DcStickerPicker* self);
static void ___lambda28__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
VALA_EXTERN gchar** dc_sticker_store_list_packs (gint* result_length1);
VALA_EXTERN DcSticker** dc_sticker_store_list_stickers (const gchar* pack,
                                            gint* result_length1);
static void _vala_array_add47 (DcSticker** * array,
                        gint* length,
                        gint* size,
                        DcSticker* value);
static void dc_sticker_picker_rebuild_filter_bar (DcStickerPicker* self);
static void dc_sticker_picker_populate (DcStickerPicker* self);
static Block64Data* block64_data_ref (Block64Data* _data64_);
static void block64_data_unref (void * _userdata_);
static void dc_sticker_picker_clear_box (GtkBox* box);
static void _vala_array_add48 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void __lambda31_ (Block64Data* _data64_);
static void dc_sticker_picker_set_filter (DcStickerPicker* self,
                                   const gchar* emoji);
static void ___lambda31__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                             gpointer self);
static Block65Data* block65_data_ref (Block65Data* _data65_);
static void block65_data_unref (void * _userdata_);
static void ____lambda33_ (Block65Data* _data65_);
static void _____lambda33__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                               gpointer self);
static GtkWidget* dc_sticker_picker_pack_header (const gchar* pack);
static GtkFlowBox* dc_sticker_picker_new_sticker_grid (void);
static GtkWidget* dc_sticker_picker_sticker_button (DcStickerPicker* self,
                                             DcSticker* sticker);
static Block66Data* block66_data_ref (Block66Data* _data66_);
static void block66_data_unref (void * _userdata_);
VALA_EXTERN gchar* dc_sticker_store_sticker_path (const gchar* file_name);
static void __lambda32_ (Block66Data* _data66_);
static void ___lambda32__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void dc_sticker_picker_finalize (GObject * obj);
static GType dc_sticker_picker_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 first-frame thumbnail for a sticker file, at most size×size
        logical pixels (kept at device resolution on HiDPI displays). */
GtkWidget*
dc_sticker_thumbnail (const gchar* path,
                      gint scale_factor,
                      gint size)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	GError* _inner_error0_ = NULL;
	GtkWidget* result;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = g_utf8_strdown (path, (gssize) -1);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_str_has_suffix (_tmp1_, ".webm");
	_g_free0 (_tmp1_);
	if (_tmp2_) {
		GtkMediaFile* media = NULL;
		GtkMediaFile* _tmp3_;
		GtkMediaFile* _tmp4_;
		GtkPicture* _tmp5_;
		_tmp3_ = (GtkMediaFile*) gtk_media_file_new_for_filename (path);
		media = _tmp3_;
		_tmp4_ = media;
		_tmp5_ = dc_sticker_thumb_picture ((GdkPaintable*) _tmp4_, size);
		result = (GtkWidget*) _tmp5_;
		_g_object_unref0 (media);
		return result;
	}
	{
		GdkPixbuf* frame = NULL;
		GdkPixbuf* _tmp6_;
		GdkPixbuf* _tmp7_;
		GdkTexture* _tmp8_;
		GdkTexture* _tmp9_;
		GtkPicture* _tmp10_;
		GtkWidget* _tmp11_;
		_tmp6_ = dc_scaled_frame_from_file (path, size * scale_factor, &_inner_error0_);
		frame = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp7_ = frame;
		_tmp8_ = dc_texture_from_pixbuf (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = dc_sticker_thumb_picture ((GdkPaintable*) _tmp9_, size);
		_tmp11_ = (GtkWidget*) _tmp10_;
		_g_object_unref0 (_tmp9_);
		result = _tmp11_;
		_g_object_unref0 (frame);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GtkImage* icon = NULL;
		GtkImage* _tmp12_;
		GtkImage* _tmp13_;
		GtkImage* _tmp14_;
		g_clear_error (&_inner_error0_);
		_tmp12_ = (GtkImage*) gtk_image_new_from_icon_name ("image-x-generic-symbolic");
		g_object_ref_sink (_tmp12_);
		icon = _tmp12_;
		_tmp13_ = icon;
		gtk_image_set_pixel_size (_tmp13_, 32);
		_tmp14_ = icon;
		gtk_widget_set_size_request ((GtkWidget*) _tmp14_, size, size);
		result = (GtkWidget*) icon;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

GtkPicture*
dc_sticker_thumb_picture (GdkPaintable* paintable,
                          gint size)
{
	GtkPicture* picture = NULL;
	GtkPicture* _tmp0_;
	GtkPicture* result;
	g_return_val_if_fail (paintable != NULL, NULL);
	_tmp0_ = (GtkPicture*) gtk_picture_new_for_paintable (paintable);
	g_object_ref_sink (_tmp0_);
	picture = _tmp0_;
	gtk_picture_set_content_fit (picture, GTK_CONTENT_FIT_CONTAIN);
	gtk_widget_set_size_request ((GtkWidget*) picture, size, size);
	result = picture;
	return result;
}

static inline gpointer
dc_sticker_picker_get_instance_private (DcStickerPicker* self)
{
	return G_STRUCT_MEMBER_P (self, DcStickerPicker_private_offset);
}

static void
__lambda28_ (DcStickerPicker* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	_tmp0_ = gtk_widget_get_visible ((GtkWidget*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		dc_sticker_picker_reload (self);
	}
}

static void
___lambda28__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda28_ ((DcStickerPicker*) self);
}

DcStickerPicker*
dc_sticker_picker_construct (GType object_type)
{
	DcStickerPicker * self = NULL;
	GtkBox* content = NULL;
	GtkBox* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	GtkBox* _tmp10_;
	GtkBox* _tmp11_;
	GtkBox* _tmp12_;
	GtkBox* pane = NULL;
	GtkBox* _tmp13_;
	GtkLabel* _tmp14_;
	GtkBox* _tmp15_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp16_;
	GtkBox* _tmp17_;
	GtkBox* _tmp18_;
	GtkBox* _tmp19_;
	GtkBox* _tmp20_;
	GtkBox* _tmp21_;
	GtkScrolledWindow* filter_scroll = NULL;
	GtkScrolledWindow* _tmp22_;
	GtkBox* _tmp23_;
	GtkBox* _tmp24_;
	GtkBox* _tmp25_;
	GtkSeparator* _tmp26_;
	GtkSeparator* _tmp27_;
	GtkBox* _tmp28_;
	GtkBox* _tmp29_;
	self = (DcStickerPicker*) g_object_new (object_type, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp0_);
	content = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new ("No stickers yet.\nRight-click a sticker in a conversation\n" "and choose \"Add Sticker…\".");
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->placeholder);
	self->priv->placeholder = _tmp1_;
	_tmp2_ = self->priv->placeholder;
	gtk_widget_add_css_class ((GtkWidget*) _tmp2_, "dim-label");
	_tmp3_ = self->priv->placeholder;
	gtk_label_set_justify (_tmp3_, GTK_JUSTIFY_CENTER);
	_tmp4_ = self->priv->placeholder;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp4_, 24);
	_tmp5_ = self->priv->placeholder;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp5_, 24);
	_tmp6_ = self->priv->placeholder;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp6_, 12);
	_tmp7_ = self->priv->placeholder;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp7_, 12);
	_tmp8_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->sections);
	self->priv->sections = _tmp8_;
	_tmp9_ = self->priv->sections;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp9_, 8);
	_tmp10_ = self->priv->sections;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp10_, 8);
	_tmp11_ = self->priv->sections;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp11_, 8);
	_tmp12_ = self->priv->sections;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp12_, 8);
	_tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp13_);
	pane = _tmp13_;
	_tmp14_ = self->priv->placeholder;
	gtk_box_append (pane, (GtkWidget*) _tmp14_);
	_tmp15_ = self->priv->sections;
	gtk_box_append (pane, (GtkWidget*) _tmp15_);
	_tmp16_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp16_);
	scroll = _tmp16_;
	g_object_set (scroll, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_scrolled_window_set_min_content_height (scroll, 320);
	gtk_scrolled_window_set_max_content_height (scroll, 320);
	gtk_scrolled_window_set_min_content_width (scroll, 336);
	gtk_scrolled_window_set_max_content_width (scroll, 336);
	gtk_widget_set_vexpand ((GtkWidget*) scroll, TRUE);
	gtk_scrolled_window_set_child (scroll, (GtkWidget*) pane);
	gtk_box_append (content, (GtkWidget*) scroll);
	_tmp17_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
	g_object_ref_sink (_tmp17_);
	_g_object_unref0 (self->priv->filter_bar);
	self->priv->filter_bar = _tmp17_;
	_tmp18_ = self->priv->filter_bar;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp18_, 4);
	_tmp19_ = self->priv->filter_bar;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp19_, 4);
	_tmp20_ = self->priv->filter_bar;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp20_, 4);
	_tmp21_ = self->priv->filter_bar;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp21_, 4);
	_tmp22_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp22_);
	filter_scroll = _tmp22_;
	g_object_set (filter_scroll, "vscrollbar-policy", GTK_POLICY_NEVER, NULL);
	g_object_set (filter_scroll, "hscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
	gtk_widget_set_hexpand ((GtkWidget*) filter_scroll, TRUE);
	_tmp23_ = self->priv->filter_bar;
	gtk_scrolled_window_set_child (filter_scroll, (GtkWidget*) _tmp23_);
	_tmp24_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->footer);
	self->priv->footer = _tmp24_;
	_tmp25_ = self->priv->footer;
	_tmp26_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp26_);
	_tmp27_ = _tmp26_;
	gtk_box_append (_tmp25_, (GtkWidget*) _tmp27_);
	_g_object_unref0 (_tmp27_);
	_tmp28_ = self->priv->footer;
	gtk_box_append (_tmp28_, (GtkWidget*) filter_scroll);
	_tmp29_ = self->priv->footer;
	gtk_box_append (content, (GtkWidget*) _tmp29_);
	gtk_popover_set_child ((GtkPopover*) self, (GtkWidget*) content);
	g_signal_connect_object ((GObject*) self, "notify::visible", (GCallback) ___lambda28__g_object_notify, self, 0);
	_g_object_unref0 (filter_scroll);
	_g_object_unref0 (scroll);
	_g_object_unref0 (pane);
	_g_object_unref0 (content);
	return self;
}

DcStickerPicker*
dc_sticker_picker_new (void)
{
	return dc_sticker_picker_construct (DC_TYPE_STICKER_PICKER);
}

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

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

static void
dc_sticker_picker_reload (DcStickerPicker* self)
{
	DcSticker** _tmp0_;
	gint _tmp1_ = 0;
	gchar** _tmp2_;
	gchar* _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_new0 (DcSticker*, 0 + 1);
	self->priv->stickers = (_vala_array_free (self->priv->stickers, self->priv->stickers_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->stickers = _tmp0_;
	self->priv->stickers_length1 = 0;
	self->priv->_stickers_size_ = self->priv->stickers_length1;
	_tmp2_ = dc_sticker_store_list_packs (&_tmp1_);
	{
		gchar** pack_collection = NULL;
		gint pack_collection_length1 = 0;
		gint _pack_collection_size_ = 0;
		gint pack_it = 0;
		pack_collection = _tmp2_;
		pack_collection_length1 = _tmp1_;
		for (pack_it = 0; pack_it < pack_collection_length1; pack_it = pack_it + 1) {
			gchar* _tmp3_;
			gchar* pack = NULL;
			_tmp3_ = g_strdup (pack_collection[pack_it]);
			pack = _tmp3_;
			{
				const gchar* _tmp4_;
				gint _tmp5_ = 0;
				DcSticker** _tmp6_;
				_tmp4_ = pack;
				_tmp6_ = dc_sticker_store_list_stickers (_tmp4_, &_tmp5_);
				{
					DcSticker** s_collection = NULL;
					gint s_collection_length1 = 0;
					gint _s_collection_size_ = 0;
					gint s_it = 0;
					s_collection = _tmp6_;
					s_collection_length1 = _tmp5_;
					for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
						DcSticker* _tmp7_;
						DcSticker* s = NULL;
						_tmp7_ = _g_object_ref0 (s_collection[s_it]);
						s = _tmp7_;
						{
							DcSticker* _tmp8_;
							DcSticker* _tmp9_;
							_tmp8_ = s;
							_tmp9_ = _g_object_ref0 (_tmp8_);
							_vala_array_add47 (&self->priv->stickers, &self->priv->stickers_length1, &self->priv->_stickers_size_, _tmp9_);
							_g_object_unref0 (s);
						}
					}
					s_collection = (_vala_array_free (s_collection, s_collection_length1, (GDestroyNotify) g_object_unref), NULL);
				}
				_g_free0 (pack);
			}
		}
		pack_collection = (_vala_array_free (pack_collection, pack_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp10_ = g_strdup ("");
	_g_free0 (self->priv->filter_emoji);
	self->priv->filter_emoji = _tmp10_;
	dc_sticker_picker_rebuild_filter_bar (self);
	dc_sticker_picker_populate (self);
}

static Block64Data*
block64_data_ref (Block64Data* _data64_)
{
	g_atomic_int_inc (&_data64_->_ref_count_);
	return _data64_;
}

static void
block64_data_unref (void * _userdata_)
{
	Block64Data* _data64_;
	_data64_ = (Block64Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data64_->_ref_count_)) {
		DcStickerPicker* self;
		self = _data64_->self;
		_g_object_unref0 (_data64_->all_btn);
		_g_object_unref0 (self);
		g_slice_free (Block64Data, _data64_);
	}
}

static void
_vala_array_add48 (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
__lambda31_ (Block64Data* _data64_)
{
	DcStickerPicker* self;
	GtkToggleButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	self = _data64_->self;
	_tmp0_ = _data64_->all_btn;
	_tmp1_ = gtk_toggle_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		dc_sticker_picker_set_filter (self, "");
	}
}

static void
___lambda31__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                        gpointer self)
{
	__lambda31_ (self);
}

static Block65Data*
block65_data_ref (Block65Data* _data65_)
{
	g_atomic_int_inc (&_data65_->_ref_count_);
	return _data65_;
}

static void
block65_data_unref (void * _userdata_)
{
	Block65Data* _data65_;
	_data65_ = (Block65Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data65_->_ref_count_)) {
		DcStickerPicker* self;
		self = _data65_->_data64_->self;
		_g_free0 (_data65_->wanted);
		_g_object_unref0 (_data65_->btn);
		block64_data_unref (_data65_->_data64_);
		_data65_->_data64_ = NULL;
		g_slice_free (Block65Data, _data65_);
	}
}

static void
____lambda33_ (Block65Data* _data65_)
{
	Block64Data* _data64_;
	DcStickerPicker* self;
	GtkToggleButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_data64_ = _data65_->_data64_;
	self = _data64_->self;
	_tmp0_ = _data65_->btn;
	_tmp1_ = gtk_toggle_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		const gchar* _tmp3_;
		_tmp3_ = _data65_->wanted;
		dc_sticker_picker_set_filter (self, _tmp3_);
	}
}

static void
_____lambda33__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                          gpointer self)
{
	____lambda33_ (self);
}

static void
dc_sticker_picker_rebuild_filter_bar (DcStickerPicker* self)
{
	Block64Data* _data64_;
	GtkBox* _tmp0_;
	gchar** emojis = NULL;
	gchar** _tmp1_;
	gint emojis_length1;
	gint _emojis_size_;
	DcSticker** _tmp2_;
	gint _tmp2__length1;
	GtkBox* _tmp16_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	gchar** _tmp18_;
	gint _tmp18__length1;
	GtkToggleButton* _tmp19_;
	GtkToggleButton* _tmp20_;
	GtkToggleButton* _tmp21_;
	GtkToggleButton* _tmp22_;
	GtkToggleButton* _tmp23_;
	GtkToggleButton* _tmp24_;
	GtkBox* _tmp25_;
	GtkToggleButton* _tmp26_;
	gchar** _tmp27_;
	gint _tmp27__length1;
	g_return_if_fail (self != NULL);
	_data64_ = g_slice_new0 (Block64Data);
	_data64_->_ref_count_ = 1;
	_data64_->self = g_object_ref (self);
	_tmp0_ = self->priv->filter_bar;
	dc_sticker_picker_clear_box (_tmp0_);
	_tmp1_ = g_new0 (gchar*, 0 + 1);
	emojis = _tmp1_;
	emojis_length1 = 0;
	_emojis_size_ = emojis_length1;
	_tmp2_ = self->priv->stickers;
	_tmp2__length1 = self->priv->stickers_length1;
	{
		DcSticker** s_collection = NULL;
		gint s_collection_length1 = 0;
		gint _s_collection_size_ = 0;
		gint s_it = 0;
		s_collection = _tmp2_;
		s_collection_length1 = _tmp2__length1;
		for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
			DcSticker* _tmp3_;
			DcSticker* s = NULL;
			_tmp3_ = _g_object_ref0 (s_collection[s_it]);
			s = _tmp3_;
			{
				DcSticker* _tmp4_;
				const gchar* _tmp5_;
				gint _tmp6_;
				gint _tmp7_;
				gboolean known = FALSE;
				gchar** _tmp8_;
				gint _tmp8__length1;
				_tmp4_ = s;
				_tmp5_ = _tmp4_->emoji;
				_tmp6_ = strlen (_tmp5_);
				_tmp7_ = _tmp6_;
				if (_tmp7_ == 0) {
					_g_object_unref0 (s);
					continue;
				}
				known = FALSE;
				_tmp8_ = emojis;
				_tmp8__length1 = emojis_length1;
				{
					gchar** e_collection = NULL;
					gint e_collection_length1 = 0;
					gint _e_collection_size_ = 0;
					gint e_it = 0;
					e_collection = _tmp8_;
					e_collection_length1 = _tmp8__length1;
					for (e_it = 0; e_it < e_collection_length1; e_it = e_it + 1) {
						gchar* _tmp9_;
						gchar* e = NULL;
						_tmp9_ = g_strdup (e_collection[e_it]);
						e = _tmp9_;
						{
							const gchar* _tmp10_;
							DcSticker* _tmp11_;
							const gchar* _tmp12_;
							_tmp10_ = e;
							_tmp11_ = s;
							_tmp12_ = _tmp11_->emoji;
							if (g_strcmp0 (_tmp10_, _tmp12_) == 0) {
								known = TRUE;
							}
							_g_free0 (e);
						}
					}
				}
				if (!known) {
					DcSticker* _tmp13_;
					const gchar* _tmp14_;
					gchar* _tmp15_;
					_tmp13_ = s;
					_tmp14_ = _tmp13_->emoji;
					_tmp15_ = g_strdup (_tmp14_);
					_vala_array_add48 (&emojis, &emojis_length1, &_emojis_size_, _tmp15_);
				}
				_g_object_unref0 (s);
			}
		}
	}
	_tmp16_ = self->priv->footer;
	_tmp17_ = emojis;
	_tmp17__length1 = emojis_length1;
	gtk_widget_set_visible ((GtkWidget*) _tmp16_, _tmp17__length1 > 0);
	_tmp18_ = emojis;
	_tmp18__length1 = emojis_length1;
	if (_tmp18__length1 == 0) {
		emojis = (_vala_array_free (emojis, emojis_length1, (GDestroyNotify) g_free), NULL);
		block64_data_unref (_data64_);
		_data64_ = NULL;
		return;
	}
	_tmp19_ = (GtkToggleButton*) gtk_toggle_button_new ();
	g_object_ref_sink (_tmp19_);
	_data64_->all_btn = _tmp19_;
	_tmp20_ = _data64_->all_btn;
	gtk_button_set_icon_name ((GtkButton*) _tmp20_, "view-grid-symbolic");
	_tmp21_ = _data64_->all_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp21_, "All stickers");
	_tmp22_ = _data64_->all_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp22_, "flat");
	_tmp23_ = _data64_->all_btn;
	gtk_toggle_button_set_active (_tmp23_, TRUE);
	_tmp24_ = _data64_->all_btn;
	g_signal_connect_data (_tmp24_, "toggled", (GCallback) ___lambda31__gtk_toggle_button_toggled, block64_data_ref (_data64_), (GClosureNotify) block64_data_unref, 0);
	_tmp25_ = self->priv->filter_bar;
	_tmp26_ = _data64_->all_btn;
	gtk_box_append (_tmp25_, (GtkWidget*) _tmp26_);
	_tmp27_ = emojis;
	_tmp27__length1 = emojis_length1;
	{
		gchar** emoji_collection = NULL;
		gint emoji_collection_length1 = 0;
		gint _emoji_collection_size_ = 0;
		gint emoji_it = 0;
		emoji_collection = _tmp27_;
		emoji_collection_length1 = _tmp27__length1;
		for (emoji_it = 0; emoji_it < emoji_collection_length1; emoji_it = emoji_it + 1) {
			gchar* _tmp28_;
			gchar* emoji = NULL;
			_tmp28_ = g_strdup (emoji_collection[emoji_it]);
			emoji = _tmp28_;
			{
				Block65Data* _data65_;
				const gchar* _tmp29_;
				GtkToggleButton* _tmp30_;
				GtkToggleButton* _tmp31_;
				GtkToggleButton* _tmp32_;
				GtkToggleButton* _tmp33_;
				const gchar* _tmp34_;
				gchar* _tmp35_;
				GtkToggleButton* _tmp36_;
				GtkBox* _tmp37_;
				GtkToggleButton* _tmp38_;
				_data65_ = g_slice_new0 (Block65Data);
				_data65_->_ref_count_ = 1;
				_data65_->_data64_ = block64_data_ref (_data64_);
				_tmp29_ = emoji;
				_tmp30_ = (GtkToggleButton*) gtk_toggle_button_new_with_label (_tmp29_);
				g_object_ref_sink (_tmp30_);
				_data65_->btn = _tmp30_;
				_tmp31_ = _data65_->btn;
				gtk_widget_add_css_class ((GtkWidget*) _tmp31_, "flat");
				_tmp32_ = _data65_->btn;
				_tmp33_ = _data64_->all_btn;
				gtk_toggle_button_set_group (_tmp32_, _tmp33_);
				_tmp34_ = emoji;
				_tmp35_ = g_strdup (_tmp34_);
				_data65_->wanted = _tmp35_;
				_tmp36_ = _data65_->btn;
				g_signal_connect_data (_tmp36_, "toggled", (GCallback) _____lambda33__gtk_toggle_button_toggled, block65_data_ref (_data65_), (GClosureNotify) block65_data_unref, 0);
				_tmp37_ = self->priv->filter_bar;
				_tmp38_ = _data65_->btn;
				gtk_box_append (_tmp37_, (GtkWidget*) _tmp38_);
				_g_free0 (emoji);
				block65_data_unref (_data65_);
				_data65_ = NULL;
			}
		}
	}
	emojis = (_vala_array_free (emojis, emojis_length1, (GDestroyNotify) g_free), NULL);
	block64_data_unref (_data64_);
	_data64_ = NULL;
}

static void
dc_sticker_picker_set_filter (DcStickerPicker* self,
                              const gchar* emoji)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (emoji != NULL);
	_tmp0_ = self->priv->filter_emoji;
	if (g_strcmp0 (_tmp0_, emoji) == 0) {
		return;
	}
	_tmp1_ = g_strdup (emoji);
	_g_free0 (self->priv->filter_emoji);
	self->priv->filter_emoji = _tmp1_;
	dc_sticker_picker_populate (self);
}

static void
dc_sticker_picker_populate (DcStickerPicker* self)
{
	GtkBox* _tmp0_;
	gboolean any = FALSE;
	gchar* pack = NULL;
	GtkFlowBox* grid = NULL;
	DcSticker** _tmp1_;
	gint _tmp1__length1;
	GtkLabel* _tmp29_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->sections;
	dc_sticker_picker_clear_box (_tmp0_);
	any = FALSE;
	pack = NULL;
	grid = NULL;
	_tmp1_ = self->priv->stickers;
	_tmp1__length1 = self->priv->stickers_length1;
	{
		DcSticker** sticker_collection = NULL;
		gint sticker_collection_length1 = 0;
		gint _sticker_collection_size_ = 0;
		gint sticker_it = 0;
		sticker_collection = _tmp1_;
		sticker_collection_length1 = _tmp1__length1;
		for (sticker_it = 0; sticker_it < sticker_collection_length1; sticker_it = sticker_it + 1) {
			DcSticker* _tmp2_;
			DcSticker* sticker = NULL;
			_tmp2_ = _g_object_ref0 (sticker_collection[sticker_it]);
			sticker = _tmp2_;
			{
				gboolean _tmp3_ = FALSE;
				const gchar* _tmp4_;
				gint _tmp5_;
				gint _tmp6_;
				gboolean _tmp10_ = FALSE;
				const gchar* _tmp11_;
				GtkFlowBox* _tmp25_;
				DcSticker* _tmp26_;
				GtkWidget* _tmp27_;
				GtkWidget* _tmp28_;
				_tmp4_ = self->priv->filter_emoji;
				_tmp5_ = strlen (_tmp4_);
				_tmp6_ = _tmp5_;
				if (_tmp6_ > 0) {
					DcSticker* _tmp7_;
					const gchar* _tmp8_;
					const gchar* _tmp9_;
					_tmp7_ = sticker;
					_tmp8_ = _tmp7_->emoji;
					_tmp9_ = self->priv->filter_emoji;
					_tmp3_ = g_strcmp0 (_tmp8_, _tmp9_) != 0;
				} else {
					_tmp3_ = FALSE;
				}
				if (_tmp3_) {
					_g_object_unref0 (sticker);
					continue;
				}
				any = TRUE;
				_tmp11_ = pack;
				if (_tmp11_ == NULL) {
					_tmp10_ = TRUE;
				} else {
					const gchar* _tmp12_;
					DcSticker* _tmp13_;
					const gchar* _tmp14_;
					_tmp12_ = pack;
					_tmp13_ = sticker;
					_tmp14_ = _tmp13_->pack;
					_tmp10_ = g_strcmp0 (_tmp12_, _tmp14_) != 0;
				}
				if (_tmp10_) {
					DcSticker* _tmp15_;
					const gchar* _tmp16_;
					gchar* _tmp17_;
					GtkBox* _tmp18_;
					const gchar* _tmp19_;
					GtkWidget* _tmp20_;
					GtkWidget* _tmp21_;
					GtkFlowBox* _tmp22_;
					GtkBox* _tmp23_;
					GtkFlowBox* _tmp24_;
					_tmp15_ = sticker;
					_tmp16_ = _tmp15_->pack;
					_tmp17_ = g_strdup (_tmp16_);
					_g_free0 (pack);
					pack = _tmp17_;
					_tmp18_ = self->priv->sections;
					_tmp19_ = pack;
					_tmp20_ = dc_sticker_picker_pack_header (_tmp19_);
					_tmp21_ = _tmp20_;
					gtk_box_append (_tmp18_, _tmp21_);
					_g_object_unref0 (_tmp21_);
					_tmp22_ = dc_sticker_picker_new_sticker_grid ();
					_g_object_unref0 (grid);
					grid = _tmp22_;
					_tmp23_ = self->priv->sections;
					_tmp24_ = grid;
					gtk_box_append (_tmp23_, (GtkWidget*) _tmp24_);
				}
				_tmp25_ = grid;
				_tmp26_ = sticker;
				_tmp27_ = dc_sticker_picker_sticker_button (self, _tmp26_);
				_tmp28_ = _tmp27_;
				gtk_flow_box_append (_tmp25_, _tmp28_);
				_g_object_unref0 (_tmp28_);
				_g_object_unref0 (sticker);
			}
		}
	}
	_tmp29_ = self->priv->placeholder;
	gtk_widget_set_visible ((GtkWidget*) _tmp29_, !any);
	_g_object_unref0 (grid);
	_g_free0 (pack);
}

static GtkWidget*
dc_sticker_picker_pack_header (const gchar* pack)
{
	GtkBox* header = NULL;
	GtkBox* _tmp0_;
	GtkLabel* label = NULL;
	GtkLabel* _tmp1_;
	GtkSeparator* line = NULL;
	GtkSeparator* _tmp2_;
	GtkWidget* result;
	g_return_val_if_fail (pack != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp0_);
	header = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (pack);
	g_object_ref_sink (_tmp1_);
	label = _tmp1_;
	gtk_widget_add_css_class ((GtkWidget*) label, "dim-label");
	gtk_widget_add_css_class ((GtkWidget*) label, "caption-heading");
	gtk_widget_set_halign ((GtkWidget*) label, GTK_ALIGN_START);
	gtk_box_append (header, (GtkWidget*) label);
	_tmp2_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp2_);
	line = _tmp2_;
	gtk_widget_set_hexpand ((GtkWidget*) line, TRUE);
	gtk_widget_set_valign ((GtkWidget*) line, GTK_ALIGN_CENTER);
	gtk_box_append (header, (GtkWidget*) line);
	result = (GtkWidget*) header;
	_g_object_unref0 (line);
	_g_object_unref0 (label);
	return result;
}

static GtkFlowBox*
dc_sticker_picker_new_sticker_grid (void)
{
	GtkFlowBox* grid = NULL;
	GtkFlowBox* _tmp0_;
	GtkFlowBox* result;
	_tmp0_ = (GtkFlowBox*) gtk_flow_box_new ();
	g_object_ref_sink (_tmp0_);
	grid = _tmp0_;
	gtk_flow_box_set_selection_mode (grid, GTK_SELECTION_NONE);
	gtk_flow_box_set_min_children_per_line (grid, (guint) DC_STICKER_PICKER_COLUMNS);
	gtk_flow_box_set_max_children_per_line (grid, (guint) DC_STICKER_PICKER_COLUMNS);
	gtk_flow_box_set_homogeneous (grid, TRUE);
	gtk_flow_box_set_column_spacing (grid, (guint) 4);
	gtk_flow_box_set_row_spacing (grid, (guint) 4);
	gtk_widget_set_valign ((GtkWidget*) grid, GTK_ALIGN_START);
	result = grid;
	return result;
}

static Block66Data*
block66_data_ref (Block66Data* _data66_)
{
	g_atomic_int_inc (&_data66_->_ref_count_);
	return _data66_;
}

static void
block66_data_unref (void * _userdata_)
{
	Block66Data* _data66_;
	_data66_ = (Block66Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data66_->_ref_count_)) {
		DcStickerPicker* self;
		self = _data66_->self;
		_g_object_unref0 (_data66_->sticker);
		_g_object_unref0 (self);
		g_slice_free (Block66Data, _data66_);
	}
}

static void
__lambda32_ (Block66Data* _data66_)
{
	DcStickerPicker* self;
	self = _data66_->self;
	gtk_popover_popdown ((GtkPopover*) self);
	g_signal_emit (self, dc_sticker_picker_signals[DC_STICKER_PICKER_STICKER_PICKED_SIGNAL], 0, _data66_->sticker);
}

static void
___lambda32__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda32_ (self);
}

static GtkWidget*
dc_sticker_picker_sticker_button (DcStickerPicker* self,
                                  DcSticker* sticker)
{
	Block66Data* _data66_;
	DcSticker* _tmp0_;
	GtkButton* btn = NULL;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	gchar* _tmp3_ = NULL;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	GtkButton* _tmp12_;
	GtkButton* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	GtkWidget* _tmp17_;
	GtkWidget* _tmp18_;
	GtkButton* _tmp19_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (sticker != NULL, NULL);
	_data66_ = g_slice_new0 (Block66Data);
	_data66_->_ref_count_ = 1;
	_data66_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (sticker);
	_g_object_unref0 (_data66_->sticker);
	_data66_->sticker = _tmp0_;
	_tmp1_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp1_);
	btn = _tmp1_;
	_tmp2_ = btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp2_, "flat");
	_tmp4_ = _data66_->sticker->emoji;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_ > 0) {
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp7_ = _data66_->sticker->emoji;
		_tmp8_ = _data66_->sticker->display_name;
		_tmp9_ = g_strdup_printf ("%s %s", _tmp7_, _tmp8_);
		_g_free0 (_tmp3_);
		_tmp3_ = _tmp9_;
	} else {
		const gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp10_ = _data66_->sticker->display_name;
		_tmp11_ = g_strdup (_tmp10_);
		_g_free0 (_tmp3_);
		_tmp3_ = _tmp11_;
	}
	_tmp12_ = btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp12_, _tmp3_);
	_tmp13_ = btn;
	_tmp14_ = _data66_->sticker->file_name;
	_tmp15_ = dc_sticker_store_sticker_path (_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = dc_sticker_thumbnail (_tmp16_, MAX (1, gtk_widget_get_scale_factor ((GtkWidget*) self)), DC_STICKER_PICKER_THUMB_SIZE);
	_tmp18_ = _tmp17_;
	gtk_button_set_child (_tmp13_, _tmp18_);
	_g_object_unref0 (_tmp18_);
	_g_free0 (_tmp16_);
	_tmp19_ = btn;
	g_signal_connect_data (_tmp19_, "clicked", (GCallback) ___lambda32__gtk_button_clicked, block66_data_ref (_data66_), (GClosureNotify) block66_data_unref, 0);
	result = (GtkWidget*) btn;
	_g_free0 (_tmp3_);
	block66_data_unref (_data66_);
	_data66_ = NULL;
	return result;
}

static void
dc_sticker_picker_clear_box (GtkBox* box)
{
	GtkWidget* child = NULL;
	g_return_if_fail (box != NULL);
	while (TRUE) {
		GtkWidget* _tmp0_;
		GtkWidget* _tmp1_;
		GtkWidget* _tmp2_;
		GtkWidget* _tmp3_;
		_tmp0_ = gtk_widget_get_first_child ((GtkWidget*) box);
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_g_object_unref0 (child);
		child = _tmp1_;
		_tmp2_ = child;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = child;
		gtk_box_remove (box, _tmp3_);
	}
	_g_object_unref0 (child);
}

static void
dc_sticker_picker_class_init (DcStickerPickerClass * klass,
                              gpointer klass_data)
{
	dc_sticker_picker_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcStickerPicker_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_sticker_picker_finalize;
	dc_sticker_picker_signals[DC_STICKER_PICKER_STICKER_PICKED_SIGNAL] = g_signal_new ("sticker-picked", DC_TYPE_STICKER_PICKER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DC_TYPE_STICKER);
}

static void
dc_sticker_picker_instance_init (DcStickerPicker * self,
                                 gpointer klass)
{
	gchar* _tmp0_;
	DcSticker** _tmp1_;
	self->priv = dc_sticker_picker_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->filter_emoji = _tmp0_;
	_tmp1_ = g_new0 (DcSticker*, 0 + 1);
	self->priv->stickers = _tmp1_;
	self->priv->stickers_length1 = 0;
	self->priv->_stickers_size_ = self->priv->stickers_length1;
}

static void
dc_sticker_picker_finalize (GObject * obj)
{
	DcStickerPicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_STICKER_PICKER, DcStickerPicker);
	_g_object_unref0 (self->priv->sections);
	_g_object_unref0 (self->priv->placeholder);
	_g_object_unref0 (self->priv->filter_bar);
	_g_object_unref0 (self->priv->footer);
	_g_free0 (self->priv->filter_emoji);
	self->priv->stickers = (_vala_array_free (self->priv->stickers, self->priv->stickers_length1, (GDestroyNotify) g_object_unref), NULL);
	G_OBJECT_CLASS (dc_sticker_picker_parent_class)->finalize (obj);
}

/**
     * Floating sticker picker for the compose bar, shaped like the emoji
     * picker: an arrowed popover holding a scrolling pane of stickers,
     * four per row, each pack under a small named separator. The bottom
     * bar filters by the emoji associated with the stickers and scrolls
     * horizontally when the emojis do not fit.
     */
static GType
dc_sticker_picker_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcStickerPickerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_sticker_picker_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcStickerPicker), 0, (GInstanceInitFunc) dc_sticker_picker_instance_init, NULL };
	GType dc_sticker_picker_type_id;
	dc_sticker_picker_type_id = g_type_register_static (gtk_popover_get_type (), "DcStickerPicker", &g_define_type_info, 0);
	DcStickerPicker_private_offset = g_type_add_instance_private (dc_sticker_picker_type_id, sizeof (DcStickerPickerPrivate));
	return dc_sticker_picker_type_id;
}

GType
dc_sticker_picker_get_type (void)
{
	static volatile gsize dc_sticker_picker_type_id__once = 0;
	if (g_once_init_enter (&dc_sticker_picker_type_id__once)) {
		GType dc_sticker_picker_type_id;
		dc_sticker_picker_type_id = dc_sticker_picker_get_type_once ();
		g_once_init_leave (&dc_sticker_picker_type_id__once, dc_sticker_picker_type_id);
	}
	return dc_sticker_picker_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;
}

