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

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <pango/pango.h>

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

#define DC_TYPE_PINNED_MESSAGES_MANAGER (dc_pinned_messages_manager_get_type ())
#define DC_PINNED_MESSAGES_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_PINNED_MESSAGES_MANAGER, DcPinnedMessagesManager))
#define DC_PINNED_MESSAGES_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_PINNED_MESSAGES_MANAGER, DcPinnedMessagesManagerClass))
#define DC_IS_PINNED_MESSAGES_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_PINNED_MESSAGES_MANAGER))
#define DC_IS_PINNED_MESSAGES_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_PINNED_MESSAGES_MANAGER))
#define DC_PINNED_MESSAGES_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_PINNED_MESSAGES_MANAGER, DcPinnedMessagesManagerClass))

typedef struct _DcPinnedMessagesManager DcPinnedMessagesManager;
typedef struct _DcPinnedMessagesManagerClass DcPinnedMessagesManagerClass;
typedef struct _DcPinnedMessagesManagerPrivate DcPinnedMessagesManagerPrivate;

#define DC_TYPE_RPC_CLIENT (dc_rpc_client_get_type ())
#define DC_RPC_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_RPC_CLIENT, DcRpcClient))
#define DC_RPC_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_RPC_CLIENT, DcRpcClientClass))
#define DC_IS_RPC_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_RPC_CLIENT))
#define DC_IS_RPC_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_RPC_CLIENT))
#define DC_RPC_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_RPC_CLIENT, DcRpcClientClass))

typedef struct _DcRpcClient DcRpcClient;
typedef struct _DcRpcClientClass DcRpcClientClass;

#define DC_TYPE_SETTINGS_MANAGER (dc_settings_manager_get_type ())
#define DC_SETTINGS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_SETTINGS_MANAGER, DcSettingsManager))
#define DC_SETTINGS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_SETTINGS_MANAGER, DcSettingsManagerClass))
#define DC_IS_SETTINGS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_SETTINGS_MANAGER))
#define DC_IS_SETTINGS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_SETTINGS_MANAGER))
#define DC_SETTINGS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_SETTINGS_MANAGER, DcSettingsManagerClass))

typedef struct _DcSettingsManager DcSettingsManager;
typedef struct _DcSettingsManagerClass DcSettingsManagerClass;
enum  {
	DC_PINNED_MESSAGES_MANAGER_0_PROPERTY,
	DC_PINNED_MESSAGES_MANAGER_REVEALER_PROPERTY,
	DC_PINNED_MESSAGES_MANAGER_NUM_PROPERTIES
};
static GParamSpec* dc_pinned_messages_manager_properties[DC_PINNED_MESSAGES_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_key_file_unref0(var) ((var == NULL) ? NULL : (var = (g_key_file_unref (var), NULL)))

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

typedef struct _DcMessage DcMessage;
typedef struct _DcMessageClass DcMessageClass;
typedef struct _Block95Data Block95Data;
typedef struct _DcPinnedMessagesManagerUpdateBarData DcPinnedMessagesManagerUpdateBarData;
typedef struct _Block96Data Block96Data;
typedef void (*DcSettingWriter) (GKeyFile* kf, gpointer user_data);
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
enum  {
	DC_PINNED_MESSAGES_MANAGER_SCROLL_REQUESTED_SIGNAL,
	DC_PINNED_MESSAGES_MANAGER_NUM_SIGNALS
};
static guint dc_pinned_messages_manager_signals[DC_PINNED_MESSAGES_MANAGER_NUM_SIGNALS] = {0};

struct _DcPinnedMessagesManager {
	GObject parent_instance;
	DcPinnedMessagesManagerPrivate * priv;
};

struct _DcPinnedMessagesManagerClass {
	GObjectClass parent_class;
};

struct _DcPinnedMessagesManagerPrivate {
	GtkRevealer* _revealer;
	DcRpcClient* rpc;
	GtkBox* bar_content;
	gint* msg_ids;
	gint msg_ids_length1;
	gint _msg_ids_size_;
	gint current_chat_id;
	GListStore* message_store;
	DcSettingsManager* settings;
};

struct _Block95Data {
	int _ref_count_;
	DcPinnedMessagesManager* self;
	gint captured_id;
};

struct _DcPinnedMessagesManagerUpdateBarData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcPinnedMessagesManager* self;
	GtkWidget* child;
	GtkBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkBox* _tmp4_;
	GtkWidget* _tmp5_;
	gint* _tmp6_;
	gint _tmp6__length1;
	GtkRevealer* _tmp7_;
	gint* _tmp8_;
	gint _tmp8__length1;
	gint* pin_id_collection;
	gint pin_id_collection_length1;
	gint _pin_id_collection_size_;
	gint pin_id_it;
	gint pin_id;
	Block95Data* _data95_;
	gchar* text;
	gchar* sender;
	DcMessage* m;
	GListStore* _tmp9_;
	DcMessage* _tmp10_;
	DcMessage* _tmp11_;
	DcMessage* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	DcMessage* _tmp17_;
	gboolean _tmp18_;
	gboolean _tmp19_;
	const gchar* _tmp20_;
	DcMessage* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gboolean _tmp25_;
	gboolean _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	DcRpcClient* _tmp29_;
	DcMessage* fetched;
	DcRpcClient* _tmp30_;
	DcMessage* _tmp31_;
	DcMessage* _tmp32_;
	DcMessage* _tmp33_;
	const gchar* _tmp34_;
	const gchar* _tmp35_;
	gchar* _tmp36_;
	const gchar* _tmp37_;
	DcMessage* _tmp38_;
	gboolean _tmp39_;
	gboolean _tmp40_;
	const gchar* _tmp41_;
	DcMessage* _tmp42_;
	const gchar* _tmp43_;
	const gchar* _tmp44_;
	gchar* _tmp45_;
	gboolean _tmp46_;
	const gchar* _tmp47_;
	const gchar* _tmp48_;
	GtkButton* row_btn;
	GtkButton* _tmp49_;
	GtkButton* _tmp50_;
	GtkBox* row_box;
	GtkBox* _tmp51_;
	GtkLabel* pin_icon;
	GtkLabel* _tmp52_;
	GtkBox* _tmp53_;
	GtkLabel* _tmp54_;
	GtkBox* text_box;
	GtkBox* _tmp55_;
	GtkBox* _tmp56_;
	gboolean _tmp57_;
	const gchar* _tmp58_;
	const gchar* _tmp59_;
	gint _tmp60_;
	gint _tmp61_;
	GtkLabel* sender_lbl;
	const gchar* _tmp62_;
	GtkLabel* _tmp63_;
	GtkLabel* _tmp64_;
	GtkLabel* _tmp65_;
	GtkLabel* _tmp66_;
	GtkBox* _tmp67_;
	GtkLabel* _tmp68_;
	const gchar* _tmp69_;
	const gchar* _tmp70_;
	GtkLabel* text_lbl;
	GtkLabel* _tmp71_;
	GtkLabel* _tmp72_;
	GtkLabel* _tmp73_;
	GtkLabel* _tmp74_;
	GtkLabel* _tmp75_;
	GtkBox* _tmp76_;
	GtkLabel* _tmp77_;
	GtkBox* _tmp78_;
	GtkBox* _tmp79_;
	GtkButton* _tmp80_;
	GtkBox* _tmp81_;
	GtkButton* _tmp82_;
	GtkBox* outer;
	GtkBox* _tmp83_;
	GtkBox* _tmp84_;
	GtkButton* _tmp85_;
	GtkButton* _tmp86_;
	GtkButton* unpin_btn;
	GtkButton* _tmp87_;
	GtkButton* _tmp88_;
	GtkButton* _tmp89_;
	GtkButton* _tmp90_;
	GtkButton* _tmp91_;
	GtkButton* _tmp92_;
	GtkBox* _tmp93_;
	GtkButton* _tmp94_;
	GtkBox* _tmp95_;
	GtkBox* _tmp96_;
	GtkRevealer* _tmp97_;
	GtkBox* _tmp98_;
	GtkWidget* _tmp99_;
	GError* _inner_error0_;
};

struct _Block96Data {
	int _ref_count_;
	DcPinnedMessagesManager* self;
	gchar* key;
	gint* ids;
	gint ids_length1;
};

static gint DcPinnedMessagesManager_private_offset;
static gpointer dc_pinned_messages_manager_parent_class = NULL;

VALA_EXTERN GType dc_pinned_messages_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcPinnedMessagesManager, g_object_unref)
VALA_EXTERN GType dc_rpc_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRpcClient, g_object_unref)
VALA_EXTERN GType dc_settings_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSettingsManager, g_object_unref)
VALA_EXTERN DcPinnedMessagesManager* dc_pinned_messages_manager_new (GListStore* message_store,
                                                         DcSettingsManager* settings);
VALA_EXTERN DcPinnedMessagesManager* dc_pinned_messages_manager_construct (GType object_type,
                                                               GListStore* message_store,
                                                               DcSettingsManager* settings);
static void dc_pinned_messages_manager_set_revealer (DcPinnedMessagesManager* self,
                                              GtkRevealer* value);
VALA_EXTERN GtkRevealer* dc_pinned_messages_manager_get_revealer (DcPinnedMessagesManager* self);
VALA_EXTERN void dc_pinned_messages_manager_set_rpc (DcPinnedMessagesManager* self,
                                         DcRpcClient* r);
VALA_EXTERN void dc_pinned_messages_manager_load_for_chat (DcPinnedMessagesManager* self,
                                               gint chat_id);
VALA_EXTERN gchar* dc_settings_manager_get_config_path (void);
static void _vala_array_add30 (gint* * array,
                        gint* length,
                        gint* size,
                        gint value);
VALA_EXTERN gboolean dc_pinned_messages_manager_is_pinned (DcPinnedMessagesManager* self,
                                               gint msg_id);
VALA_EXTERN void dc_pinned_messages_manager_toggle_pin (DcPinnedMessagesManager* self,
                                            gint msg_id);
static void _vala_array_add31 (gint* * array,
                        gint* length,
                        gint* size,
                        gint value);
static gint* _vala_array_dup11 (gint* self,
                         gssize length);
static void _vala_array_add32 (gint* * array,
                        gint* length,
                        gint* size,
                        gint value);
static void dc_pinned_messages_manager_save_for_chat (DcPinnedMessagesManager* self,
                                               gint chat_id,
                                               gint* ids,
                                               gint ids_length1);
VALA_EXTERN GType dc_message_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessage, g_object_unref)
VALA_EXTERN DcMessage* dc_find_message (GListModel* store,
                            gint msg_id);
VALA_EXTERN void dc_message_set_is_pinned (DcMessage* self,
                               gboolean value);
static void dc_pinned_messages_manager_refresh_in_store (DcPinnedMessagesManager* self,
                                                  gint msg_id);
VALA_EXTERN void dc_pinned_messages_manager_update_bar (DcPinnedMessagesManager* self,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
VALA_EXTERN void dc_pinned_messages_manager_update_bar_finish (DcPinnedMessagesManager* self,
                                                   GAsyncResult* _res_);
static void dc_pinned_messages_manager_update_bar_data_free (gpointer _data);
static gboolean dc_pinned_messages_manager_update_bar_co (DcPinnedMessagesManagerUpdateBarData* _data_);
static Block95Data* block95_data_ref (Block95Data* _data95_);
static void block95_data_unref (void * _userdata_);
VALA_EXTERN const gchar* dc_message_get_text (DcMessage* self);
VALA_EXTERN gboolean dc_message_get_is_outgoing (DcMessage* self);
VALA_EXTERN const gchar* dc_message_get_sender_name (DcMessage* self);
VALA_EXTERN void dc_rpc_client_fetch_message (DcRpcClient* self,
                                  gint msg_id,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
VALA_EXTERN DcMessage* dc_rpc_client_fetch_message_finish (DcRpcClient* self,
                                               GAsyncResult* _res_,
                                               GError** error);
static void dc_pinned_messages_manager_update_bar_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_);
static void ____lambda64_ (Block95Data* _data95_);
static void _____lambda64__gtk_button_clicked (GtkButton* _sender,
                                        gpointer self);
static void ____lambda65_ (Block95Data* _data95_);
static void _____lambda65__gtk_button_clicked (GtkButton* _sender,
                                        gpointer self);
static Block96Data* block96_data_ref (Block96Data* _data96_);
static void block96_data_unref (void * _userdata_);
VALA_EXTERN void dc_settings_manager_save_to_file (DcSettingsManager* self,
                                       DcSettingWriter writer,
                                       gpointer writer_target);
static void __lambda63_ (Block96Data* _data96_,
                  GKeyFile* kf);
static void ___lambda63__dc_setting_writer (GKeyFile* kf,
                                     gpointer self);
VALA_EXTERN gint dc_find_message_index (GListModel* store,
                            gint msg_id);
static void dc_pinned_messages_manager_finalize (GObject * obj);
static GType dc_pinned_messages_manager_get_type_once (void);
static void _vala_dc_pinned_messages_manager_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_dc_pinned_messages_manager_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dc_pinned_messages_manager_get_instance_private (DcPinnedMessagesManager* self)
{
	return G_STRUCT_MEMBER_P (self, DcPinnedMessagesManager_private_offset);
}

DcPinnedMessagesManager*
dc_pinned_messages_manager_construct (GType object_type,
                                      GListStore* message_store,
                                      DcSettingsManager* settings)
{
	DcPinnedMessagesManager * self = NULL;
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	GtkRevealer* _tmp2_;
	GtkRevealer* _tmp3_;
	GtkRevealer* _tmp4_;
	GtkBox* _tmp5_;
	GtkRevealer* _tmp6_;
	GtkRevealer* _tmp7_;
	g_return_val_if_fail (message_store != NULL, NULL);
	g_return_val_if_fail (settings != NULL, NULL);
	self = (DcPinnedMessagesManager*) g_object_new (object_type, NULL);
	self->priv->message_store = message_store;
	self->priv->settings = settings;
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->bar_content);
	self->priv->bar_content = _tmp0_;
	_tmp1_ = self->priv->bar_content;
	gtk_widget_add_css_class ((GtkWidget*) _tmp1_, "pinned-bar");
	_tmp2_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	dc_pinned_messages_manager_set_revealer (self, _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->_revealer;
	_tmp5_ = self->priv->bar_content;
	gtk_revealer_set_child (_tmp4_, (GtkWidget*) _tmp5_);
	_tmp6_ = self->priv->_revealer;
	gtk_revealer_set_reveal_child (_tmp6_, FALSE);
	_tmp7_ = self->priv->_revealer;
	gtk_revealer_set_transition_type (_tmp7_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
	return self;
}

DcPinnedMessagesManager*
dc_pinned_messages_manager_new (GListStore* message_store,
                                DcSettingsManager* settings)
{
	return dc_pinned_messages_manager_construct (DC_TYPE_PINNED_MESSAGES_MANAGER, message_store, settings);
}

void
dc_pinned_messages_manager_set_rpc (DcPinnedMessagesManager* self,
                                    DcRpcClient* r)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (r != NULL);
	self->priv->rpc = r;
}

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

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

void
dc_pinned_messages_manager_load_for_chat (DcPinnedMessagesManager* self,
                                          gint chat_id)
{
	gint* _tmp0_;
	GKeyFile* kf = NULL;
	GKeyFile* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	self->priv->current_chat_id = chat_id;
	_tmp0_ = g_new0 (gint, 0);
	self->priv->msg_ids = (g_free (self->priv->msg_ids), NULL);
	self->priv->msg_ids = _tmp0_;
	self->priv->msg_ids_length1 = 0;
	self->priv->_msg_ids_size_ = self->priv->msg_ids_length1;
	_tmp1_ = g_key_file_new ();
	kf = _tmp1_;
	{
		GKeyFile* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* key = NULL;
		gchar* _tmp5_;
		gchar* val = NULL;
		GKeyFile* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		const gchar* _tmp9_;
		gchar** _tmp10_;
		gchar** _tmp11_;
		_tmp2_ = kf;
		_tmp3_ = dc_settings_manager_get_config_path ();
		_tmp4_ = _tmp3_;
		g_key_file_load_from_file (_tmp2_, _tmp4_, G_KEY_FILE_NONE, &_inner_error0_);
		_g_free0 (_tmp4_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp5_ = g_strdup_printf ("chat_%d", chat_id);
		key = _tmp5_;
		_tmp6_ = kf;
		_tmp7_ = key;
		_tmp8_ = g_key_file_get_string (_tmp6_, "PinnedMessages", _tmp7_, &_inner_error0_);
		val = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (key);
			goto __catch0_g_error;
		}
		_tmp9_ = val;
		_tmp11_ = _tmp10_ = g_strsplit (_tmp9_, ",", 0);
		{
			gchar** s_collection = NULL;
			gint s_collection_length1 = 0;
			gint _s_collection_size_ = 0;
			gint s_it = 0;
			s_collection = _tmp11_;
			s_collection_length1 = _vala_array_length (_tmp10_);
			for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
				gchar* _tmp12_;
				gchar* s = NULL;
				_tmp12_ = g_strdup (s_collection[s_it]);
				s = _tmp12_;
				{
					gchar* trimmed = NULL;
					const gchar* _tmp13_;
					gchar* _tmp14_;
					const gchar* _tmp15_;
					gint _tmp16_;
					gint _tmp17_;
					_tmp13_ = s;
					_tmp14_ = string_strip (_tmp13_);
					trimmed = _tmp14_;
					_tmp15_ = trimmed;
					_tmp16_ = strlen (_tmp15_);
					_tmp17_ = _tmp16_;
					if (_tmp17_ > 0) {
						const gchar* _tmp18_;
						_tmp18_ = trimmed;
						_vala_array_add30 (&self->priv->msg_ids, &self->priv->msg_ids_length1, &self->priv->_msg_ids_size_, atoi (_tmp18_));
					}
					_g_free0 (trimmed);
					_g_free0 (s);
				}
			}
			s_collection = (_vala_array_free (s_collection, s_collection_length1, (GDestroyNotify) g_free), NULL);
		}
		_g_free0 (val);
		_g_free0 (key);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_key_file_unref0 (kf);
		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_key_file_unref0 (kf);
}

gboolean
dc_pinned_messages_manager_is_pinned (DcPinnedMessagesManager* self,
                                      gint msg_id)
{
	gint* _tmp0_;
	gint _tmp0__length1;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->msg_ids;
	_tmp0__length1 = self->priv->msg_ids_length1;
	{
		gint* id_collection = NULL;
		gint id_collection_length1 = 0;
		gint _id_collection_size_ = 0;
		gint id_it = 0;
		id_collection = _tmp0_;
		id_collection_length1 = _tmp0__length1;
		for (id_it = 0; id_it < id_collection_length1; id_it = id_it + 1) {
			gint id = 0;
			id = id_collection[id_it];
			{
				if (id == msg_id) {
					result = TRUE;
					return result;
				}
			}
		}
	}
	result = FALSE;
	return result;
}

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

static gint*
_vala_array_dup11 (gint* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gint));
	}
	return NULL;
}

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

void
dc_pinned_messages_manager_toggle_pin (DcPinnedMessagesManager* self,
                                       gint msg_id)
{
	gint* _tmp4_;
	gint _tmp4__length1;
	DcMessage* m = NULL;
	GListStore* _tmp5_;
	DcMessage* _tmp6_;
	DcMessage* _tmp7_;
	g_return_if_fail (self != NULL);
	if (dc_pinned_messages_manager_is_pinned (self, msg_id)) {
		gint* new_ids = NULL;
		gint* _tmp0_;
		gint new_ids_length1;
		gint _new_ids_size_;
		gint* _tmp1_;
		gint _tmp1__length1;
		gint* _tmp2_;
		gint _tmp2__length1;
		gint* _tmp3_;
		gint _tmp3__length1;
		_tmp0_ = g_new0 (gint, 0);
		new_ids = _tmp0_;
		new_ids_length1 = 0;
		_new_ids_size_ = new_ids_length1;
		_tmp1_ = self->priv->msg_ids;
		_tmp1__length1 = self->priv->msg_ids_length1;
		{
			gint* id_collection = NULL;
			gint id_collection_length1 = 0;
			gint _id_collection_size_ = 0;
			gint id_it = 0;
			id_collection = _tmp1_;
			id_collection_length1 = _tmp1__length1;
			for (id_it = 0; id_it < id_collection_length1; id_it = id_it + 1) {
				gint id = 0;
				id = id_collection[id_it];
				{
					if (id != msg_id) {
						_vala_array_add31 (&new_ids, &new_ids_length1, &_new_ids_size_, id);
					}
				}
			}
		}
		_tmp2_ = new_ids;
		_tmp2__length1 = new_ids_length1;
		_tmp3_ = (_tmp2_ != NULL) ? _vala_array_dup11 (_tmp2_, _tmp2__length1) : _tmp2_;
		_tmp3__length1 = _tmp2__length1;
		self->priv->msg_ids = (g_free (self->priv->msg_ids), NULL);
		self->priv->msg_ids = _tmp3_;
		self->priv->msg_ids_length1 = _tmp3__length1;
		self->priv->_msg_ids_size_ = self->priv->msg_ids_length1;
		new_ids = (g_free (new_ids), NULL);
	} else {
		_vala_array_add32 (&self->priv->msg_ids, &self->priv->msg_ids_length1, &self->priv->_msg_ids_size_, msg_id);
	}
	_tmp4_ = self->priv->msg_ids;
	_tmp4__length1 = self->priv->msg_ids_length1;
	dc_pinned_messages_manager_save_for_chat (self, self->priv->current_chat_id, _tmp4_, (gint) _tmp4__length1);
	_tmp5_ = self->priv->message_store;
	_tmp6_ = dc_find_message ((GListModel*) _tmp5_, msg_id);
	m = _tmp6_;
	_tmp7_ = m;
	if (_tmp7_ != NULL) {
		DcMessage* _tmp8_;
		DcMessage* _tmp9_;
		_tmp8_ = m;
		dc_message_set_is_pinned (_tmp8_, dc_pinned_messages_manager_is_pinned (self, msg_id));
		_tmp9_ = m;
		g_object_notify ((GObject*) _tmp9_, "is-pinned");
		dc_pinned_messages_manager_refresh_in_store (self, msg_id);
	}
	dc_pinned_messages_manager_update_bar (self, NULL, NULL);
	_g_object_unref0 (m);
}

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

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

void
dc_pinned_messages_manager_update_bar (DcPinnedMessagesManager* self,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	DcPinnedMessagesManagerUpdateBarData* _data_;
	DcPinnedMessagesManager* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcPinnedMessagesManagerUpdateBarData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_pinned_messages_manager_update_bar_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_pinned_messages_manager_update_bar_co (_data_);
}

void
dc_pinned_messages_manager_update_bar_finish (DcPinnedMessagesManager* self,
                                              GAsyncResult* _res_)
{
	DcPinnedMessagesManagerUpdateBarData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block95Data*
block95_data_ref (Block95Data* _data95_)
{
	g_atomic_int_inc (&_data95_->_ref_count_);
	return _data95_;
}

static void
block95_data_unref (void * _userdata_)
{
	Block95Data* _data95_;
	_data95_ = (Block95Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data95_->_ref_count_)) {
		DcPinnedMessagesManager* self;
		self = _data95_->self;
		_g_object_unref0 (self);
		g_slice_free (Block95Data, _data95_);
	}
}

static void
dc_pinned_messages_manager_update_bar_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_)
{
	DcPinnedMessagesManagerUpdateBarData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_pinned_messages_manager_update_bar_co (_data_);
}

static void
____lambda64_ (Block95Data* _data95_)
{
	DcPinnedMessagesManager* self;
	self = _data95_->self;
	g_signal_emit (self, dc_pinned_messages_manager_signals[DC_PINNED_MESSAGES_MANAGER_SCROLL_REQUESTED_SIGNAL], 0, _data95_->captured_id);
}

static void
_____lambda64__gtk_button_clicked (GtkButton* _sender,
                                   gpointer self)
{
	____lambda64_ (self);
}

static void
____lambda65_ (Block95Data* _data95_)
{
	DcPinnedMessagesManager* self;
	self = _data95_->self;
	dc_pinned_messages_manager_toggle_pin (self, _data95_->captured_id);
}

static void
_____lambda65__gtk_button_clicked (GtkButton* _sender,
                                   gpointer self)
{
	____lambda65_ (self);
}

static gboolean
dc_pinned_messages_manager_update_bar_co (DcPinnedMessagesManagerUpdateBarData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	while (TRUE) {
		_data_->_tmp0_ = _data_->self->priv->bar_content;
		_data_->_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _data_->_tmp0_);
		_data_->_tmp2_ = _g_object_ref0 (_data_->_tmp1_);
		_g_object_unref0 (_data_->child);
		_data_->child = _data_->_tmp2_;
		_data_->_tmp3_ = _data_->child;
		if (!(_data_->_tmp3_ != NULL)) {
			break;
		}
		_data_->_tmp4_ = _data_->self->priv->bar_content;
		_data_->_tmp5_ = _data_->child;
		gtk_box_remove (_data_->_tmp4_, _data_->_tmp5_);
	}
	_data_->_tmp6_ = _data_->self->priv->msg_ids;
	_data_->_tmp6__length1 = _data_->self->priv->msg_ids_length1;
	if (_data_->_tmp6__length1 == 0) {
		_data_->_tmp7_ = _data_->self->priv->_revealer;
		gtk_revealer_set_reveal_child (_data_->_tmp7_, FALSE);
		_g_object_unref0 (_data_->child);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp8_ = _data_->self->priv->msg_ids;
	_data_->_tmp8__length1 = _data_->self->priv->msg_ids_length1;
	{
		_data_->pin_id_collection_length1 = 0;
		_data_->_pin_id_collection_size_ = 0;
		_data_->pin_id_collection = _data_->_tmp8_;
		_data_->pin_id_collection_length1 = _data_->_tmp8__length1;
		for (_data_->pin_id_it = 0; _data_->pin_id_it < _data_->pin_id_collection_length1; _data_->pin_id_it = _data_->pin_id_it + 1) {
			_data_->pin_id = _data_->pin_id_collection[_data_->pin_id_it];
			{
				_data_->_data95_ = g_slice_new0 (Block95Data);
				_data_->_data95_->_ref_count_ = 1;
				_data_->_data95_->self = g_object_ref (_data_->self);
				_data_->text = NULL;
				_data_->sender = NULL;
				_data_->_tmp9_ = _data_->self->priv->message_store;
				_data_->_tmp10_ = dc_find_message ((GListModel*) _data_->_tmp9_, _data_->pin_id);
				_data_->m = _data_->_tmp10_;
				_data_->_tmp11_ = _data_->m;
				if (_data_->_tmp11_ != NULL) {
					_data_->_tmp12_ = _data_->m;
					_data_->_tmp13_ = dc_message_get_text (_data_->_tmp12_);
					_data_->_tmp14_ = _data_->_tmp13_;
					_data_->_tmp15_ = g_strdup (_data_->_tmp14_);
					_g_free0 (_data_->text);
					_data_->text = _data_->_tmp15_;
					_data_->_tmp17_ = _data_->m;
					_data_->_tmp18_ = dc_message_get_is_outgoing (_data_->_tmp17_);
					_data_->_tmp19_ = _data_->_tmp18_;
					if (_data_->_tmp19_) {
						_data_->_tmp16_ = "You";
					} else {
						_data_->_tmp21_ = _data_->m;
						_data_->_tmp22_ = dc_message_get_sender_name (_data_->_tmp21_);
						_data_->_tmp23_ = _data_->_tmp22_;
						_data_->_tmp20_ = _data_->_tmp23_;
						if (_data_->_tmp20_ == NULL) {
							_data_->_tmp20_ = "";
						}
						_data_->_tmp16_ = _data_->_tmp20_;
					}
					_data_->_tmp24_ = g_strdup (_data_->_tmp16_);
					_g_free0 (_data_->sender);
					_data_->sender = _data_->_tmp24_;
				}
				_data_->_tmp27_ = _data_->text;
				if (_data_->_tmp27_ == NULL) {
					_data_->_tmp28_ = _data_->sender;
					_data_->_tmp26_ = _data_->_tmp28_ == NULL;
				} else {
					_data_->_tmp26_ = FALSE;
				}
				if (_data_->_tmp26_) {
					_data_->_tmp29_ = _data_->self->priv->rpc;
					_data_->_tmp25_ = _data_->_tmp29_ != NULL;
				} else {
					_data_->_tmp25_ = FALSE;
				}
				if (_data_->_tmp25_) {
					{
						_data_->_tmp30_ = _data_->self->priv->rpc;
						_data_->_state_ = 1;
						dc_rpc_client_fetch_message (_data_->_tmp30_, _data_->pin_id, dc_pinned_messages_manager_update_bar_ready, _data_);
						return FALSE;
						_state_1:
						_data_->_tmp31_ = dc_rpc_client_fetch_message_finish (_data_->_tmp30_, _data_->_res_, &_data_->_inner_error0_);
						_data_->fetched = _data_->_tmp31_;
						if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
							goto __catch0_g_error;
						}
						_data_->_tmp32_ = _data_->fetched;
						if (_data_->_tmp32_ != NULL) {
							_data_->_tmp33_ = _data_->fetched;
							_data_->_tmp34_ = dc_message_get_text (_data_->_tmp33_);
							_data_->_tmp35_ = _data_->_tmp34_;
							_data_->_tmp36_ = g_strdup (_data_->_tmp35_);
							_g_free0 (_data_->text);
							_data_->text = _data_->_tmp36_;
							_data_->_tmp38_ = _data_->fetched;
							_data_->_tmp39_ = dc_message_get_is_outgoing (_data_->_tmp38_);
							_data_->_tmp40_ = _data_->_tmp39_;
							if (_data_->_tmp40_) {
								_data_->_tmp37_ = "You";
							} else {
								_data_->_tmp42_ = _data_->fetched;
								_data_->_tmp43_ = dc_message_get_sender_name (_data_->_tmp42_);
								_data_->_tmp44_ = _data_->_tmp43_;
								_data_->_tmp41_ = _data_->_tmp44_;
								if (_data_->_tmp41_ == NULL) {
									_data_->_tmp41_ = "";
								}
								_data_->_tmp37_ = _data_->_tmp41_;
							}
							_data_->_tmp45_ = g_strdup (_data_->_tmp37_);
							_g_free0 (_data_->sender);
							_data_->sender = _data_->_tmp45_;
						}
						_g_object_unref0 (_data_->fetched);
					}
					goto __finally0;
					__catch0_g_error:
					{
						g_clear_error (&_data_->_inner_error0_);
					}
					__finally0:
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						_g_object_unref0 (_data_->m);
						_g_free0 (_data_->sender);
						_g_free0 (_data_->text);
						block95_data_unref (_data_->_data95_);
						_data_->_data95_ = NULL;
						_g_object_unref0 (_data_->child);
						g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
						g_clear_error (&_data_->_inner_error0_);
						g_object_unref (_data_->_async_result);
						return FALSE;
					}
				}
				_data_->_tmp47_ = _data_->text;
				if (_data_->_tmp47_ == NULL) {
					_data_->_tmp48_ = _data_->sender;
					_data_->_tmp46_ = _data_->_tmp48_ == NULL;
				} else {
					_data_->_tmp46_ = FALSE;
				}
				if (_data_->_tmp46_) {
					_g_object_unref0 (_data_->m);
					_g_free0 (_data_->sender);
					_g_free0 (_data_->text);
					block95_data_unref (_data_->_data95_);
					_data_->_data95_ = NULL;
					continue;
				}
				_data_->_tmp49_ = (GtkButton*) gtk_button_new ();
				g_object_ref_sink (_data_->_tmp49_);
				_data_->row_btn = _data_->_tmp49_;
				_data_->_tmp50_ = _data_->row_btn;
				gtk_widget_add_css_class ((GtkWidget*) _data_->_tmp50_, "flat");
				_data_->_tmp51_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
				g_object_ref_sink (_data_->_tmp51_);
				_data_->row_box = _data_->_tmp51_;
				_data_->_tmp52_ = (GtkLabel*) gtk_label_new ("\xf0\x9f\x93\x8c");
				g_object_ref_sink (_data_->_tmp52_);
				_data_->pin_icon = _data_->_tmp52_;
				_data_->_tmp53_ = _data_->row_box;
				_data_->_tmp54_ = _data_->pin_icon;
				gtk_box_append (_data_->_tmp53_, (GtkWidget*) _data_->_tmp54_);
				_data_->_tmp55_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
				g_object_ref_sink (_data_->_tmp55_);
				_data_->text_box = _data_->_tmp55_;
				_data_->_tmp56_ = _data_->text_box;
				gtk_widget_set_hexpand ((GtkWidget*) _data_->_tmp56_, TRUE);
				_data_->_tmp58_ = _data_->sender;
				if (_data_->_tmp58_ != NULL) {
					_data_->_tmp59_ = _data_->sender;
					_data_->_tmp60_ = strlen (_data_->_tmp59_);
					_data_->_tmp61_ = _data_->_tmp60_;
					_data_->_tmp57_ = _data_->_tmp61_ > 0;
				} else {
					_data_->_tmp57_ = FALSE;
				}
				if (_data_->_tmp57_) {
					_data_->_tmp62_ = _data_->sender;
					_data_->_tmp63_ = (GtkLabel*) gtk_label_new (_data_->_tmp62_);
					g_object_ref_sink (_data_->_tmp63_);
					_data_->sender_lbl = _data_->_tmp63_;
					_data_->_tmp64_ = _data_->sender_lbl;
					gtk_widget_add_css_class ((GtkWidget*) _data_->_tmp64_, "caption");
					_data_->_tmp65_ = _data_->sender_lbl;
					gtk_widget_add_css_class ((GtkWidget*) _data_->_tmp65_, "dim-label");
					_data_->_tmp66_ = _data_->sender_lbl;
					gtk_widget_set_halign ((GtkWidget*) _data_->_tmp66_, GTK_ALIGN_START);
					_data_->_tmp67_ = _data_->text_box;
					_data_->_tmp68_ = _data_->sender_lbl;
					gtk_box_append (_data_->_tmp67_, (GtkWidget*) _data_->_tmp68_);
					_g_object_unref0 (_data_->sender_lbl);
				}
				_data_->_tmp70_ = _data_->text;
				_data_->_tmp69_ = _data_->_tmp70_;
				if (_data_->_tmp69_ == NULL) {
					_data_->_tmp69_ = "(attachment)";
				}
				_data_->_tmp71_ = (GtkLabel*) gtk_label_new (_data_->_tmp69_);
				g_object_ref_sink (_data_->_tmp71_);
				_data_->text_lbl = _data_->_tmp71_;
				_data_->_tmp72_ = _data_->text_lbl;
				gtk_widget_set_halign ((GtkWidget*) _data_->_tmp72_, GTK_ALIGN_START);
				_data_->_tmp73_ = _data_->text_lbl;
				gtk_label_set_ellipsize (_data_->_tmp73_, PANGO_ELLIPSIZE_END);
				_data_->_tmp74_ = _data_->text_lbl;
				gtk_label_set_max_width_chars (_data_->_tmp74_, 50);
				_data_->_tmp75_ = _data_->text_lbl;
				gtk_label_set_lines (_data_->_tmp75_, 1);
				_data_->_tmp76_ = _data_->text_box;
				_data_->_tmp77_ = _data_->text_lbl;
				gtk_box_append (_data_->_tmp76_, (GtkWidget*) _data_->_tmp77_);
				_data_->_tmp78_ = _data_->row_box;
				_data_->_tmp79_ = _data_->text_box;
				gtk_box_append (_data_->_tmp78_, (GtkWidget*) _data_->_tmp79_);
				_data_->_tmp80_ = _data_->row_btn;
				_data_->_tmp81_ = _data_->row_box;
				gtk_button_set_child (_data_->_tmp80_, (GtkWidget*) _data_->_tmp81_);
				_data_->_data95_->captured_id = _data_->pin_id;
				_data_->_tmp82_ = _data_->row_btn;
				g_signal_connect_data (_data_->_tmp82_, "clicked", (GCallback) _____lambda64__gtk_button_clicked, block95_data_ref (_data_->_data95_), (GClosureNotify) block95_data_unref, 0);
				_data_->_tmp83_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
				g_object_ref_sink (_data_->_tmp83_);
				_data_->outer = _data_->_tmp83_;
				_data_->_tmp84_ = _data_->outer;
				_data_->_tmp85_ = _data_->row_btn;
				gtk_box_append (_data_->_tmp84_, (GtkWidget*) _data_->_tmp85_);
				_data_->_tmp86_ = _data_->row_btn;
				gtk_widget_set_hexpand ((GtkWidget*) _data_->_tmp86_, TRUE);
				_data_->_tmp87_ = (GtkButton*) gtk_button_new_from_icon_name ("window-close-symbolic");
				g_object_ref_sink (_data_->_tmp87_);
				_data_->unpin_btn = _data_->_tmp87_;
				_data_->_tmp88_ = _data_->unpin_btn;
				gtk_widget_add_css_class ((GtkWidget*) _data_->_tmp88_, "flat");
				_data_->_tmp89_ = _data_->unpin_btn;
				gtk_widget_add_css_class ((GtkWidget*) _data_->_tmp89_, "circular");
				_data_->_tmp90_ = _data_->unpin_btn;
				gtk_widget_set_valign ((GtkWidget*) _data_->_tmp90_, GTK_ALIGN_CENTER);
				_data_->_tmp91_ = _data_->unpin_btn;
				gtk_widget_set_tooltip_text ((GtkWidget*) _data_->_tmp91_, "Unpin");
				_data_->_tmp92_ = _data_->unpin_btn;
				g_signal_connect_data (_data_->_tmp92_, "clicked", (GCallback) _____lambda65__gtk_button_clicked, block95_data_ref (_data_->_data95_), (GClosureNotify) block95_data_unref, 0);
				_data_->_tmp93_ = _data_->outer;
				_data_->_tmp94_ = _data_->unpin_btn;
				gtk_box_append (_data_->_tmp93_, (GtkWidget*) _data_->_tmp94_);
				_data_->_tmp95_ = _data_->self->priv->bar_content;
				_data_->_tmp96_ = _data_->outer;
				gtk_box_append (_data_->_tmp95_, (GtkWidget*) _data_->_tmp96_);
				_g_object_unref0 (_data_->unpin_btn);
				_g_object_unref0 (_data_->outer);
				_g_object_unref0 (_data_->text_lbl);
				_g_object_unref0 (_data_->text_box);
				_g_object_unref0 (_data_->pin_icon);
				_g_object_unref0 (_data_->row_box);
				_g_object_unref0 (_data_->row_btn);
				_g_object_unref0 (_data_->m);
				_g_free0 (_data_->sender);
				_g_free0 (_data_->text);
				block95_data_unref (_data_->_data95_);
				_data_->_data95_ = NULL;
			}
		}
	}
	_data_->_tmp97_ = _data_->self->priv->_revealer;
	_data_->_tmp98_ = _data_->self->priv->bar_content;
	_data_->_tmp99_ = gtk_widget_get_first_child ((GtkWidget*) _data_->_tmp98_);
	gtk_revealer_set_reveal_child (_data_->_tmp97_, _data_->_tmp99_ != NULL);
	_g_object_unref0 (_data_->child);
	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 Block96Data*
block96_data_ref (Block96Data* _data96_)
{
	g_atomic_int_inc (&_data96_->_ref_count_);
	return _data96_;
}

static void
block96_data_unref (void * _userdata_)
{
	Block96Data* _data96_;
	_data96_ = (Block96Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data96_->_ref_count_)) {
		DcPinnedMessagesManager* self;
		self = _data96_->self;
		_g_free0 (_data96_->key);
		_g_object_unref0 (self);
		g_slice_free (Block96Data, _data96_);
	}
}

static void
__lambda63_ (Block96Data* _data96_,
             GKeyFile* kf)
{
	DcPinnedMessagesManager* self;
	GError* _inner_error0_ = NULL;
	self = _data96_->self;
	g_return_if_fail (kf != NULL);
	if (_data96_->ids_length1 > 0) {
		GString* sb = NULL;
		GString* _tmp0_;
		GString* _tmp6_;
		const gchar* _tmp7_;
		_tmp0_ = g_string_new ("");
		sb = _tmp0_;
		{
			gint* id_collection = NULL;
			gint id_collection_length1 = 0;
			gint _id_collection_size_ = 0;
			gint id_it = 0;
			id_collection = _data96_->ids;
			id_collection_length1 = _data96_->ids_length1;
			for (id_it = 0; id_it < id_collection_length1; id_it = id_it + 1) {
				gint id = 0;
				id = id_collection[id_it];
				{
					GString* _tmp1_;
					GString* _tmp3_;
					gchar* _tmp4_;
					gchar* _tmp5_;
					_tmp1_ = sb;
					if (_tmp1_->len > ((gssize) 0)) {
						GString* _tmp2_;
						_tmp2_ = sb;
						g_string_append (_tmp2_, ",");
					}
					_tmp3_ = sb;
					_tmp4_ = g_strdup_printf ("%i", id);
					_tmp5_ = _tmp4_;
					g_string_append (_tmp3_, _tmp5_);
					_g_free0 (_tmp5_);
				}
			}
		}
		_tmp6_ = sb;
		_tmp7_ = _tmp6_->str;
		g_key_file_set_string (kf, "PinnedMessages", _data96_->key, _tmp7_);
		_g_string_free0 (sb);
	} else {
		{
			g_key_file_remove_key (kf, "PinnedMessages", _data96_->key, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_inner_error0_);
		}
		__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
___lambda63__dc_setting_writer (GKeyFile* kf,
                                gpointer self)
{
	__lambda63_ (self, kf);
}

static void
dc_pinned_messages_manager_save_for_chat (DcPinnedMessagesManager* self,
                                          gint chat_id,
                                          gint* ids,
                                          gint ids_length1)
{
	Block96Data* _data96_;
	gchar* _tmp0_;
	DcSettingsManager* _tmp1_;
	g_return_if_fail (self != NULL);
	_data96_ = g_slice_new0 (Block96Data);
	_data96_->_ref_count_ = 1;
	_data96_->self = g_object_ref (self);
	_data96_->ids = ids;
	_data96_->ids_length1 = ids_length1;
	_tmp0_ = g_strdup_printf ("chat_%d", chat_id);
	_data96_->key = _tmp0_;
	_tmp1_ = self->priv->settings;
	dc_settings_manager_save_to_file (_tmp1_, ___lambda63__dc_setting_writer, _data96_);
	block96_data_unref (_data96_);
	_data96_ = NULL;
}

static void
dc_pinned_messages_manager_refresh_in_store (DcPinnedMessagesManager* self,
                                             gint msg_id)
{
	gint idx = 0;
	GListStore* _tmp0_;
	DcMessage* m = NULL;
	GListStore* _tmp1_;
	GObject* _tmp2_;
	GObject** replacements = NULL;
	DcMessage* _tmp3_;
	GObject* _tmp4_;
	GObject** _tmp5_;
	gint replacements_length1;
	gint _replacements_size_;
	GListStore* _tmp6_;
	GObject** _tmp7_;
	gint _tmp7__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->message_store;
	idx = dc_find_message_index ((GListModel*) _tmp0_, msg_id);
	if (idx < 0) {
		return;
	}
	_tmp1_ = self->priv->message_store;
	_tmp2_ = g_list_model_get_item ((GListModel*) _tmp1_, (guint) idx);
	m = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, DC_TYPE_MESSAGE, DcMessage);
	_tmp3_ = m;
	_tmp4_ = _g_object_ref0 ((GObject*) _tmp3_);
	_tmp5_ = g_new0 (GObject*, 1 + 1);
	_tmp5_[0] = _tmp4_;
	replacements = _tmp5_;
	replacements_length1 = 1;
	_replacements_size_ = replacements_length1;
	_tmp6_ = self->priv->message_store;
	_tmp7_ = replacements;
	_tmp7__length1 = replacements_length1;
	g_list_store_splice (_tmp6_, (guint) idx, (guint) 1, _tmp7_, (guint) _tmp7__length1);
	replacements = (_vala_array_free (replacements, replacements_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (m);
}

GtkRevealer*
dc_pinned_messages_manager_get_revealer (DcPinnedMessagesManager* self)
{
	GtkRevealer* result;
	GtkRevealer* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_revealer;
	result = _tmp0_;
	return result;
}

static void
dc_pinned_messages_manager_set_revealer (DcPinnedMessagesManager* self,
                                         GtkRevealer* value)
{
	GtkRevealer* old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_pinned_messages_manager_get_revealer (self);
	if (old_value != value) {
		GtkRevealer* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_revealer);
		self->priv->_revealer = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_pinned_messages_manager_properties[DC_PINNED_MESSAGES_MANAGER_REVEALER_PROPERTY]);
	}
}

static void
dc_pinned_messages_manager_class_init (DcPinnedMessagesManagerClass * klass,
                                       gpointer klass_data)
{
	dc_pinned_messages_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcPinnedMessagesManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_pinned_messages_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_pinned_messages_manager_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_pinned_messages_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_PINNED_MESSAGES_MANAGER_REVEALER_PROPERTY, dc_pinned_messages_manager_properties[DC_PINNED_MESSAGES_MANAGER_REVEALER_PROPERTY] = g_param_spec_object ("revealer", "revealer", "revealer", gtk_revealer_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	dc_pinned_messages_manager_signals[DC_PINNED_MESSAGES_MANAGER_SCROLL_REQUESTED_SIGNAL] = g_signal_new ("scroll-requested", DC_TYPE_PINNED_MESSAGES_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
}

static void
dc_pinned_messages_manager_instance_init (DcPinnedMessagesManager * self,
                                          gpointer klass)
{
	gint* _tmp0_;
	self->priv = dc_pinned_messages_manager_get_instance_private (self);
	self->priv->rpc = NULL;
	_tmp0_ = g_new0 (gint, 0);
	self->priv->msg_ids = _tmp0_;
	self->priv->msg_ids_length1 = 0;
	self->priv->_msg_ids_size_ = self->priv->msg_ids_length1;
	self->priv->current_chat_id = 0;
}

static void
dc_pinned_messages_manager_finalize (GObject * obj)
{
	DcPinnedMessagesManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_PINNED_MESSAGES_MANAGER, DcPinnedMessagesManager);
	_g_object_unref0 (self->priv->_revealer);
	_g_object_unref0 (self->priv->bar_content);
	self->priv->msg_ids = (g_free (self->priv->msg_ids), NULL);
	G_OBJECT_CLASS (dc_pinned_messages_manager_parent_class)->finalize (obj);
}

static GType
dc_pinned_messages_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcPinnedMessagesManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_pinned_messages_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcPinnedMessagesManager), 0, (GInstanceInitFunc) dc_pinned_messages_manager_instance_init, NULL };
	GType dc_pinned_messages_manager_type_id;
	dc_pinned_messages_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "DcPinnedMessagesManager", &g_define_type_info, 0);
	DcPinnedMessagesManager_private_offset = g_type_add_instance_private (dc_pinned_messages_manager_type_id, sizeof (DcPinnedMessagesManagerPrivate));
	return dc_pinned_messages_manager_type_id;
}

GType
dc_pinned_messages_manager_get_type (void)
{
	static volatile gsize dc_pinned_messages_manager_type_id__once = 0;
	if (g_once_init_enter (&dc_pinned_messages_manager_type_id__once)) {
		GType dc_pinned_messages_manager_type_id;
		dc_pinned_messages_manager_type_id = dc_pinned_messages_manager_get_type_once ();
		g_once_init_leave (&dc_pinned_messages_manager_type_id__once, dc_pinned_messages_manager_type_id);
	}
	return dc_pinned_messages_manager_type_id__once;
}

static void
_vala_dc_pinned_messages_manager_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	DcPinnedMessagesManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_PINNED_MESSAGES_MANAGER, DcPinnedMessagesManager);
	switch (property_id) {
		case DC_PINNED_MESSAGES_MANAGER_REVEALER_PROPERTY:
		g_value_set_object (value, dc_pinned_messages_manager_get_revealer (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_pinned_messages_manager_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	DcPinnedMessagesManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_PINNED_MESSAGES_MANAGER, DcPinnedMessagesManager);
	switch (property_id) {
		case DC_PINNED_MESSAGES_MANAGER_REVEALER_PROPERTY:
		dc_pinned_messages_manager_set_revealer (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

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

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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

