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

#include <glib-object.h>
#include <gtksourceview/gtksource.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <gdk/gdk.h>

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

#define TUBA_TYPE_COMPLETION_PROVIDER (tuba_completion_provider_get_type ())
#define TUBA_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_COMPLETION_PROVIDER, TubaCompletionProvider))
#define TUBA_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_COMPLETION_PROVIDER, TubaCompletionProviderClass))
#define TUBA_IS_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_COMPLETION_PROVIDER))
#define TUBA_IS_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_COMPLETION_PROVIDER))
#define TUBA_COMPLETION_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_COMPLETION_PROVIDER, TubaCompletionProviderClass))

typedef struct _TubaCompletionProvider TubaCompletionProvider;
typedef struct _TubaCompletionProviderClass TubaCompletionProviderClass;
typedef struct _TubaCompletionProviderPrivate TubaCompletionProviderPrivate;

#define TUBA_TYPE_EMOJI_PROVIDER (tuba_emoji_provider_get_type ())
#define TUBA_EMOJI_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_EMOJI_PROVIDER, TubaEmojiProvider))
#define TUBA_EMOJI_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_EMOJI_PROVIDER, TubaEmojiProviderClass))
#define TUBA_IS_EMOJI_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_EMOJI_PROVIDER))
#define TUBA_IS_EMOJI_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_EMOJI_PROVIDER))
#define TUBA_EMOJI_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_EMOJI_PROVIDER, TubaEmojiProviderClass))

typedef struct _TubaEmojiProvider TubaEmojiProvider;
typedef struct _TubaEmojiProviderClass TubaEmojiProviderClass;
typedef struct _TubaEmojiProviderPrivate TubaEmojiProviderPrivate;
enum  {
	TUBA_EMOJI_PROVIDER_0_PROPERTY,
	TUBA_EMOJI_PROVIDER_NUM_PROPERTIES
};
static GParamSpec* tuba_emoji_provider_properties[TUBA_EMOJI_PROVIDER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block43Data Block43Data;

#define TUBA_TYPE_ENTITY (tuba_entity_get_type ())
#define TUBA_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_ENTITY, TubaEntity))
#define TUBA_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_ENTITY, TubaEntityClass))
#define TUBA_IS_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_ENTITY))
#define TUBA_IS_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_ENTITY))
#define TUBA_ENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_ENTITY, TubaEntityClass))

typedef struct _TubaEntity TubaEntity;
typedef struct _TubaEntityClass TubaEntityClass;

#define TUBA_API_TYPE_EMOJI (tuba_api_emoji_get_type ())
#define TUBA_API_EMOJI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_API_TYPE_EMOJI, TubaAPIEmoji))
#define TUBA_API_EMOJI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_API_TYPE_EMOJI, TubaAPIEmojiClass))
#define TUBA_API_IS_EMOJI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_API_TYPE_EMOJI))
#define TUBA_API_IS_EMOJI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_API_TYPE_EMOJI))
#define TUBA_API_EMOJI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_API_TYPE_EMOJI, TubaAPIEmojiClass))

typedef struct _TubaAPIEmoji TubaAPIEmoji;
typedef struct _TubaAPIEmojiClass TubaAPIEmojiClass;

#define TUBA_TYPE_ACCOUNT_STORE (tuba_account_store_get_type ())
#define TUBA_ACCOUNT_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_ACCOUNT_STORE, TubaAccountStore))
#define TUBA_ACCOUNT_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_ACCOUNT_STORE, TubaAccountStoreClass))
#define TUBA_IS_ACCOUNT_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_ACCOUNT_STORE))
#define TUBA_IS_ACCOUNT_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_ACCOUNT_STORE))
#define TUBA_ACCOUNT_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_ACCOUNT_STORE, TubaAccountStoreClass))

typedef struct _TubaAccountStore TubaAccountStore;
typedef struct _TubaAccountStoreClass TubaAccountStoreClass;

#define TUBA_API_TYPE_ACCOUNT (tuba_api_account_get_type ())
#define TUBA_API_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_API_TYPE_ACCOUNT, TubaAPIAccount))
#define TUBA_API_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_API_TYPE_ACCOUNT, TubaAPIAccountClass))
#define TUBA_API_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_API_TYPE_ACCOUNT))
#define TUBA_API_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_API_TYPE_ACCOUNT))
#define TUBA_API_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_API_TYPE_ACCOUNT, TubaAPIAccountClass))

typedef struct _TubaAPIAccount TubaAPIAccount;
typedef struct _TubaAPIAccountClass TubaAPIAccountClass;

#define TUBA_TYPE_INSTANCE_ACCOUNT (tuba_instance_account_get_type ())
#define TUBA_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_INSTANCE_ACCOUNT, TubaInstanceAccount))
#define TUBA_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_INSTANCE_ACCOUNT, TubaInstanceAccountClass))
#define TUBA_IS_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_INSTANCE_ACCOUNT))
#define TUBA_IS_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_INSTANCE_ACCOUNT))
#define TUBA_INSTANCE_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_INSTANCE_ACCOUNT, TubaInstanceAccountClass))

typedef struct _TubaInstanceAccount TubaInstanceAccount;
typedef struct _TubaInstanceAccountClass TubaInstanceAccountClass;

#define TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL (tuba_emoji_provider_proposal_get_type ())
#define TUBA_EMOJI_PROVIDER_PROPOSAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL, TubaEmojiProviderProposal))
#define TUBA_EMOJI_PROVIDER_PROPOSAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL, TubaEmojiProviderProposalClass))
#define TUBA_EMOJI_PROVIDER_IS_PROPOSAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL))
#define TUBA_EMOJI_PROVIDER_IS_PROPOSAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL))
#define TUBA_EMOJI_PROVIDER_PROPOSAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL, TubaEmojiProviderProposalClass))

typedef struct _TubaEmojiProviderProposal TubaEmojiProviderProposal;
typedef struct _TubaEmojiProviderProposalClass TubaEmojiProviderProposalClass;
typedef struct _TubaEmojiProviderSuggestData TubaEmojiProviderSuggestData;
typedef struct _Block44Data Block44Data;
typedef void (*TubaHelperImageOnItemChangedFn) (GdkPaintable* data, gpointer user_data);
typedef struct _TubaEmojiProviderProposalPrivate TubaEmojiProviderProposalPrivate;
enum  {
	TUBA_EMOJI_PROVIDER_PROPOSAL_0_PROPERTY,
	TUBA_EMOJI_PROVIDER_PROPOSAL_EMOJI_PROPERTY,
	TUBA_EMOJI_PROVIDER_PROPOSAL_NUM_PROPERTIES
};
static GParamSpec* tuba_emoji_provider_proposal_properties[TUBA_EMOJI_PROVIDER_PROPOSAL_NUM_PROPERTIES];

struct _TubaCompletionProvider {
	GObject parent_instance;
	TubaCompletionProviderPrivate * priv;
};

struct _TubaCompletionProviderClass {
	GObjectClass parent_class;
	gboolean (*is_trigger) (TubaCompletionProvider* self, GtkTextIter* iter, gunichar ch);
	void (*refilter) (TubaCompletionProvider* self, GtkSourceCompletionContext* context, GListModel* model);
	void (*activate) (TubaCompletionProvider* self, GtkSourceCompletionContext* context, GtkSourceCompletionProposal* proposal);
	void (*display) (TubaCompletionProvider* self, GtkSourceCompletionContext* context, GtkSourceCompletionProposal* proposal, GtkSourceCompletionCell* cell);
	void (*suggest) (TubaCompletionProvider* self, const gchar* word, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	GListModel* (*suggest_finish) (TubaCompletionProvider* self, GAsyncResult* _res_, GError** error);
	gboolean (*word_stop) (TubaCompletionProvider* self, gunichar ch);
	gchar* (*get_formatted_text) (TubaCompletionProvider* self, GtkSourceCompletionProposal* proposal);
};

struct _TubaEmojiProvider {
	TubaCompletionProvider parent_instance;
	TubaEmojiProviderPrivate * priv;
};

struct _TubaEmojiProviderClass {
	TubaCompletionProviderClass parent_class;
};

struct _Block43Data {
	int _ref_count_;
	TubaEmojiProvider* self;
	GListStore* results;
	gchar* new_word;
	gpointer _async_data_;
};

struct _TubaEmojiProviderSuggestData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	TubaEmojiProvider* self;
	gchar* word;
	GCancellable* cancellable;
	GListModel* result;
	Block43Data* _data43_;
	GListStore* _tmp0_;
	GeeArrayList* emojis;
	TubaAccountStore* _tmp1_;
	TubaInstanceAccount* _tmp2_;
	TubaInstanceAccount* _tmp3_;
	GeeArrayList* _tmp4_;
	GeeArrayList* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	GListStore* _tmp8_;
	GListModel* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	GeeArrayList* _tmp12_;
	GListStore* _tmp13_;
	GListModel* _tmp14_;
};

struct _Block44Data {
	int _ref_count_;
	TubaEmojiProvider* self;
	GtkImage* image;
};

struct _TubaEmojiProviderProposal {
	GObject parent_instance;
	TubaEmojiProviderProposalPrivate * priv;
};

struct _TubaEmojiProviderProposalClass {
	GObjectClass parent_class;
};

struct _TubaEmojiProviderProposalPrivate {
	TubaAPIEmoji* _emoji;
};

static gpointer tuba_emoji_provider_parent_class = NULL;
VALA_EXTERN TubaAccountStore* tuba_accounts;
static gint TubaEmojiProviderProposal_private_offset;
static gpointer tuba_emoji_provider_proposal_parent_class = NULL;
static GtkSourceCompletionProposalInterface * tuba_emoji_provider_proposal_gtk_source_completion_proposal_parent_iface = NULL;

VALA_EXTERN GType tuba_completion_provider_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaCompletionProvider, g_object_unref)
VALA_EXTERN GType tuba_emoji_provider_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaEmojiProvider, g_object_unref)
VALA_EXTERN void tuba_completion_provider_suggest (TubaCompletionProvider* self,
                                       const gchar* word,
                                       GCancellable* cancellable,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
VALA_EXTERN GListModel* tuba_completion_provider_suggest_finish (TubaCompletionProvider* self,
                                                     GAsyncResult* _res_,
                                                     GError** error);
VALA_EXTERN void tuba_completion_provider_display (TubaCompletionProvider* self,
                                       GtkSourceCompletionContext* context,
                                       GtkSourceCompletionProposal* proposal,
                                       GtkSourceCompletionCell* cell);
VALA_EXTERN gboolean tuba_completion_provider_word_stop (TubaCompletionProvider* self,
                                             gunichar ch);
VALA_EXTERN TubaEmojiProvider* tuba_emoji_provider_new (void);
VALA_EXTERN TubaEmojiProvider* tuba_emoji_provider_construct (GType object_type);
static void tuba_emoji_provider_real_suggest_data_free (gpointer _data);
static void tuba_emoji_provider_real_suggest (TubaCompletionProvider* base,
                                       const gchar* word,
                                       GCancellable* cancellable,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
static gboolean tuba_emoji_provider_real_suggest_co (TubaEmojiProviderSuggestData* _data_);
static Block43Data* block43_data_ref (Block43Data* _data43_);
static void block43_data_unref (void * _userdata_);
VALA_EXTERN GType tuba_entity_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaEntity, g_object_unref)
VALA_EXTERN GType tuba_api_emoji_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaAPIEmoji, g_object_unref)
VALA_EXTERN GType tuba_account_store_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaAccountStore, g_object_unref)
VALA_EXTERN GType tuba_api_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaAPIAccount, g_object_unref)
VALA_EXTERN GType tuba_instance_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaInstanceAccount, g_object_unref)
VALA_EXTERN TubaInstanceAccount* tuba_account_store_get_active (TubaAccountStore* self);
VALA_EXTERN GeeArrayList* tuba_instance_account_get_instance_emojis (TubaInstanceAccount* self);
static gboolean __lambda70_ (Block43Data* _data43_,
                      TubaAPIEmoji* e);
VALA_EXTERN const gchar* tuba_api_emoji_get_shortcode (TubaAPIEmoji* self);
VALA_EXTERN GType tuba_emoji_provider_proposal_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaEmojiProviderProposal, g_object_unref)
VALA_EXTERN TubaEmojiProviderProposal* tuba_emoji_provider_proposal_new (TubaAPIEmoji* entity);
VALA_EXTERN TubaEmojiProviderProposal* tuba_emoji_provider_proposal_construct (GType object_type,
                                                                   TubaAPIEmoji* entity);
static gboolean ___lambda70__gee_forall_func (gpointer g,
                                       gpointer self);
static void tuba_emoji_provider_real_display (TubaCompletionProvider* base,
                                       GtkSourceCompletionContext* context,
                                       GtkSourceCompletionProposal* proposal,
                                       GtkSourceCompletionCell* cell);
VALA_EXTERN TubaAPIEmoji* tuba_emoji_provider_proposal_get_emoji (TubaEmojiProviderProposal* self);
static Block44Data* block44_data_ref (Block44Data* _data44_);
static void block44_data_unref (void * _userdata_);
VALA_EXTERN void tuba_helper_image_request_paintable (const gchar* url,
                                          const gchar* blurhash,
                                          gboolean disable_cache,
                                          TubaHelperImageOnItemChangedFn cb,
                                          gpointer cb_target,
                                          GDestroyNotify cb_target_destroy_notify,
                                          GCancellable* cancellable);
VALA_EXTERN const gchar* tuba_api_emoji_get_url (TubaAPIEmoji* self);
static void ___lambda71_ (Block44Data* _data44_,
                   GdkPaintable* paintable);
static void ____lambda71__tuba_helper_image_on_item_changed_fn (GdkPaintable* data,
                                                         gpointer self);
static gboolean tuba_emoji_provider_real_word_stop (TubaCompletionProvider* base,
                                             gunichar ch);
VALA_EXTERN gunichar tuba_completion_provider_get_trigger_char (TubaCompletionProvider* self);
static gchar* tuba_emoji_provider_proposal_real_get_typed_text (GtkSourceCompletionProposal* base);
static void tuba_emoji_provider_proposal_set_emoji (TubaEmojiProviderProposal* self,
                                             TubaAPIEmoji* value);
static void tuba_emoji_provider_proposal_finalize (GObject * obj);
static GType tuba_emoji_provider_proposal_get_type_once (void);
static void _vala_tuba_emoji_provider_proposal_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec);
static void _vala_tuba_emoji_provider_proposal_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec);
static GType tuba_emoji_provider_get_type_once (void);

TubaEmojiProvider*
tuba_emoji_provider_construct (GType object_type)
{
	TubaEmojiProvider * self = NULL;
	self = (TubaEmojiProvider*) g_object_new (object_type, "trigger-char", ':', NULL);
	return self;
}

TubaEmojiProvider*
tuba_emoji_provider_new (void)
{
	return tuba_emoji_provider_construct (TUBA_TYPE_EMOJI_PROVIDER);
}

static void
tuba_emoji_provider_real_suggest_data_free (gpointer _data)
{
	TubaEmojiProviderSuggestData* _data_;
	_data_ = _data;
	_g_free0 (_data_->word);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (TubaEmojiProviderSuggestData, _data_);
}

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

static void
tuba_emoji_provider_real_suggest (TubaCompletionProvider* base,
                                  const gchar* word,
                                  GCancellable* cancellable,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_)
{
	TubaEmojiProvider * self;
	TubaEmojiProviderSuggestData* _data_;
	TubaEmojiProvider* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (word != NULL);
	self = (TubaEmojiProvider*) base;
	_data_ = g_slice_new0 (TubaEmojiProviderSuggestData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tuba_emoji_provider_real_suggest_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (word);
	_g_free0 (_data_->word);
	_data_->word = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	tuba_emoji_provider_real_suggest_co (_data_);
}

static GListModel*
tuba_emoji_provider_suggest_finish (TubaCompletionProvider* base,
                                    GAsyncResult* _res_,
                                    GError** error)
{
	GListModel* result;
	TubaEmojiProviderSuggestData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static Block43Data*
block43_data_ref (Block43Data* _data43_)
{
	g_atomic_int_inc (&_data43_->_ref_count_);
	return _data43_;
}

static void
block43_data_unref (void * _userdata_)
{
	Block43Data* _data43_;
	_data43_ = (Block43Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data43_->_ref_count_)) {
		TubaEmojiProvider* self;
		self = _data43_->self;
		_g_free0 (_data43_->new_word);
		_g_object_unref0 (_data43_->results);
		_g_object_unref0 (self);
		g_slice_free (Block43Data, _data43_);
	}
}

static const gchar*
string_offset (const gchar* self,
               glong offset)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = (const gchar*) (((gchar*) self) + offset);
	return result;
}

static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static gboolean
__lambda70_ (Block43Data* _data43_,
             TubaAPIEmoji* e)
{
	TubaEmojiProvider* self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gboolean _tmp5_;
	TubaEmojiProviderProposal* proposal = NULL;
	TubaEmojiProviderProposal* _tmp6_;
	GListStore* _tmp7_;
	TubaEmojiProviderProposal* _tmp8_;
	GListStore* _tmp9_;
	guint _tmp10_;
	guint _tmp11_;
	gboolean result;
	self = _data43_->self;
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = tuba_api_emoji_get_shortcode (e);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_utf8_strdown (_tmp1_, (gssize) -1);
	_tmp3_ = _tmp2_;
	_tmp4_ = _data43_->new_word;
	_tmp5_ = string_index_of (_tmp3_, _tmp4_, 0) != 0;
	_g_free0 (_tmp3_);
	if (_tmp5_) {
		result = TRUE;
		_g_object_unref0 (e);
		return result;
	}
	_tmp6_ = tuba_emoji_provider_proposal_new (e);
	proposal = _tmp6_;
	_tmp7_ = _data43_->results;
	_tmp8_ = proposal;
	g_list_store_append (_tmp7_, (GObject*) _tmp8_);
	_tmp9_ = _data43_->results;
	g_object_get (_tmp9_, "n-items", &_tmp10_, NULL);
	_tmp11_ = _tmp10_;
	result = _tmp11_ < ((guint) 4);
	_g_object_unref0 (proposal);
	_g_object_unref0 (e);
	return result;
}

static gboolean
___lambda70__gee_forall_func (gpointer g,
                              gpointer self)
{
	gboolean result;
	result = __lambda70_ (self, (TubaAPIEmoji*) g);
	return result;
}

static gboolean
tuba_emoji_provider_real_suggest_co (TubaEmojiProviderSuggestData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data43_ = g_slice_new0 (Block43Data);
	_data_->_data43_->_ref_count_ = 1;
	_data_->_data43_->self = g_object_ref (_data_->self);
	_data_->_data43_->_async_data_ = _data_;
	_data_->_tmp0_ = g_list_store_new (G_TYPE_OBJECT);
	_data_->_data43_->results = _data_->_tmp0_;
	_data_->_tmp1_ = tuba_accounts;
	_data_->_tmp2_ = tuba_account_store_get_active (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = tuba_instance_account_get_instance_emojis (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = _g_object_ref0 (_data_->_tmp5_);
	_data_->emojis = _data_->_tmp6_;
	_data_->_tmp7_ = _data_->emojis;
	if (_data_->_tmp7_ == NULL) {
		_data_->_tmp8_ = _data_->_data43_->results;
		_data_->_tmp9_ = _g_object_ref0 ((GListModel*) _data_->_tmp8_);
		_data_->result = _data_->_tmp9_;
		_g_object_unref0 (_data_->emojis);
		block43_data_unref (_data_->_data43_);
		_data_->_data43_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp10_ = string_offset (_data_->word, (glong) 1);
	_data_->_tmp11_ = g_utf8_strdown (_data_->_tmp10_, (gssize) -1);
	_data_->_data43_->new_word = _data_->_tmp11_;
	_data_->_tmp12_ = _data_->emojis;
	gee_abstract_collection_foreach ((GeeAbstractCollection*) _data_->_tmp12_, ___lambda70__gee_forall_func, _data_->_data43_);
	_data_->_tmp13_ = _data_->_data43_->results;
	_data_->_tmp14_ = _g_object_ref0 ((GListModel*) _data_->_tmp13_);
	_data_->result = _data_->_tmp14_;
	_g_object_unref0 (_data_->emojis);
	block43_data_unref (_data_->_data43_);
	_data_->_data43_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static Block44Data*
block44_data_ref (Block44Data* _data44_)
{
	g_atomic_int_inc (&_data44_->_ref_count_);
	return _data44_;
}

static void
block44_data_unref (void * _userdata_)
{
	Block44Data* _data44_;
	_data44_ = (Block44Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data44_->_ref_count_)) {
		TubaEmojiProvider* self;
		self = _data44_->self;
		_g_object_unref0 (_data44_->image);
		_g_object_unref0 (self);
		g_slice_free (Block44Data, _data44_);
	}
}

static void
___lambda71_ (Block44Data* _data44_,
              GdkPaintable* paintable)
{
	TubaEmojiProvider* self;
	GtkImage* _tmp0_;
	self = _data44_->self;
	_tmp0_ = _data44_->image;
	g_object_set (_tmp0_, "paintable", paintable, NULL);
}

static void
____lambda71__tuba_helper_image_on_item_changed_fn (GdkPaintable* data,
                                                    gpointer self)
{
	___lambda71_ (self, data);
}

static void
tuba_emoji_provider_real_display (TubaCompletionProvider* base,
                                  GtkSourceCompletionContext* context,
                                  GtkSourceCompletionProposal* proposal,
                                  GtkSourceCompletionCell* cell)
{
	TubaEmojiProvider * self;
	TubaEmojiProviderProposal* real_proposal = NULL;
	TubaEmojiProviderProposal* _tmp0_;
	TubaEmojiProviderProposal* _tmp1_;
	TubaAPIEmoji* emoji = NULL;
	TubaEmojiProviderProposal* _tmp2_;
	TubaAPIEmoji* _tmp3_;
	TubaAPIEmoji* _tmp4_;
	TubaAPIEmoji* _tmp5_;
	TubaAPIEmoji* _tmp6_;
	self = (TubaEmojiProvider*) base;
	g_return_if_fail (context != NULL);
	g_return_if_fail (proposal != NULL);
	g_return_if_fail (cell != NULL);
	_tmp0_ = _g_object_ref0 (TUBA_EMOJI_PROVIDER_IS_PROPOSAL (proposal) ? ((TubaEmojiProviderProposal*) proposal) : NULL);
	real_proposal = _tmp0_;
	_tmp1_ = real_proposal;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (real_proposal);
		return;
	}
	_tmp2_ = real_proposal;
	_tmp3_ = tuba_emoji_provider_proposal_get_emoji (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	emoji = _tmp5_;
	_tmp6_ = emoji;
	g_return_if_fail (_tmp6_ != NULL);
	switch (gtk_source_completion_cell_get_column (cell)) {
		case GTK_SOURCE_COMPLETION_COLUMN_ICON:
		{
			Block44Data* _data44_;
			GtkImage* _tmp7_ = NULL;
			TubaAPIEmoji* _tmp8_;
			const gchar* _tmp9_;
			const gchar* _tmp10_;
			GtkImage* _tmp11_;
			_data44_ = g_slice_new0 (Block44Data);
			_data44_->_ref_count_ = 1;
			_data44_->self = g_object_ref (self);
			_tmp7_ = (GtkImage*) gtk_image_new ();
			gtk_image_set_pixel_size (_tmp7_, 36);
			g_object_ref_sink (_tmp7_);
			_data44_->image = _tmp7_;
			_tmp8_ = emoji;
			_tmp9_ = tuba_api_emoji_get_url (_tmp8_);
			_tmp10_ = _tmp9_;
			tuba_helper_image_request_paintable (_tmp10_, NULL, FALSE, ____lambda71__tuba_helper_image_on_item_changed_fn, block44_data_ref (_data44_), block44_data_unref, NULL);
			_tmp11_ = _data44_->image;
			gtk_source_completion_cell_set_widget (cell, (GtkWidget*) _tmp11_);
			block44_data_unref (_data44_);
			_data44_ = NULL;
			break;
		}
		case GTK_SOURCE_COMPLETION_COLUMN_TYPED_TEXT:
		{
			gchar* _tmp12_;
			gchar* _tmp13_;
			gchar* _tmp14_;
			gchar* _tmp15_;
			_tmp12_ = gtk_source_completion_proposal_get_typed_text (proposal);
			_tmp13_ = _tmp12_;
			_tmp14_ = g_strconcat (":", _tmp13_, NULL);
			_tmp15_ = _tmp14_;
			gtk_source_completion_cell_set_markup (cell, _tmp15_);
			_g_free0 (_tmp15_);
			_g_free0 (_tmp13_);
			break;
		}
		default:
		{
			g_object_set (cell, "text", NULL, NULL);
			break;
		}
	}
	_g_object_unref0 (emoji);
	_g_object_unref0 (real_proposal);
}

static gboolean
tuba_emoji_provider_real_word_stop (TubaCompletionProvider* base,
                                    gunichar ch)
{
	TubaEmojiProvider * self;
	gboolean _tmp0_ = FALSE;
	gboolean result;
	self = (TubaEmojiProvider*) base;
	if (TUBA_COMPLETION_PROVIDER_CLASS (tuba_emoji_provider_parent_class)->word_stop (G_TYPE_CHECK_INSTANCE_CAST (self, TUBA_TYPE_COMPLETION_PROVIDER, TubaCompletionProvider), ch)) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp1_ = FALSE;
		if (!g_unichar_isalnum (ch)) {
			gunichar _tmp2_;
			gunichar _tmp3_;
			_tmp2_ = tuba_completion_provider_get_trigger_char ((TubaCompletionProvider*) self);
			_tmp3_ = _tmp2_;
			_tmp1_ = ch != _tmp3_;
		} else {
			_tmp1_ = FALSE;
		}
		_tmp0_ = _tmp1_;
	}
	result = _tmp0_;
	return result;
}

static inline gpointer
tuba_emoji_provider_proposal_get_instance_private (TubaEmojiProviderProposal* self)
{
	return G_STRUCT_MEMBER_P (self, TubaEmojiProviderProposal_private_offset);
}

TubaEmojiProviderProposal*
tuba_emoji_provider_proposal_construct (GType object_type,
                                        TubaAPIEmoji* entity)
{
	TubaEmojiProviderProposal * self = NULL;
	g_return_val_if_fail (entity != NULL, NULL);
	self = (TubaEmojiProviderProposal*) g_object_new (object_type, "emoji", entity, NULL);
	return self;
}

TubaEmojiProviderProposal*
tuba_emoji_provider_proposal_new (TubaAPIEmoji* entity)
{
	return tuba_emoji_provider_proposal_construct (TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL, entity);
}

static gchar*
tuba_emoji_provider_proposal_real_get_typed_text (GtkSourceCompletionProposal* base)
{
	TubaEmojiProviderProposal * self;
	TubaAPIEmoji* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = (TubaEmojiProviderProposal*) base;
	_tmp0_ = self->priv->_emoji;
	_tmp1_ = tuba_api_emoji_get_shortcode (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, ":", NULL);
	result = _tmp3_;
	return result;
}

TubaAPIEmoji*
tuba_emoji_provider_proposal_get_emoji (TubaEmojiProviderProposal* self)
{
	TubaAPIEmoji* result;
	TubaAPIEmoji* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_emoji;
	result = _tmp0_;
	return result;
}

static void
tuba_emoji_provider_proposal_set_emoji (TubaEmojiProviderProposal* self,
                                        TubaAPIEmoji* value)
{
	TubaAPIEmoji* old_value;
	g_return_if_fail (self != NULL);
	old_value = tuba_emoji_provider_proposal_get_emoji (self);
	if (old_value != value) {
		TubaAPIEmoji* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_emoji);
		self->priv->_emoji = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tuba_emoji_provider_proposal_properties[TUBA_EMOJI_PROVIDER_PROPOSAL_EMOJI_PROPERTY]);
	}
}

static void
tuba_emoji_provider_proposal_class_init (TubaEmojiProviderProposalClass * klass,
                                         gpointer klass_data)
{
	tuba_emoji_provider_proposal_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TubaEmojiProviderProposal_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tuba_emoji_provider_proposal_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tuba_emoji_provider_proposal_set_property;
	G_OBJECT_CLASS (klass)->finalize = tuba_emoji_provider_proposal_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TUBA_EMOJI_PROVIDER_PROPOSAL_EMOJI_PROPERTY, tuba_emoji_provider_proposal_properties[TUBA_EMOJI_PROVIDER_PROPOSAL_EMOJI_PROPERTY] = g_param_spec_object ("emoji", "emoji", "emoji", TUBA_API_TYPE_EMOJI, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
tuba_emoji_provider_proposal_gtk_source_completion_proposal_interface_init (GtkSourceCompletionProposalInterface * iface,
                                                                            gpointer iface_data)
{
	tuba_emoji_provider_proposal_gtk_source_completion_proposal_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_typed_text = (gchar* (*) (GtkSourceCompletionProposal*)) tuba_emoji_provider_proposal_real_get_typed_text;
}

static void
tuba_emoji_provider_proposal_instance_init (TubaEmojiProviderProposal * self,
                                            gpointer klass)
{
	self->priv = tuba_emoji_provider_proposal_get_instance_private (self);
}

static void
tuba_emoji_provider_proposal_finalize (GObject * obj)
{
	TubaEmojiProviderProposal * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL, TubaEmojiProviderProposal);
	_g_object_unref0 (self->priv->_emoji);
	G_OBJECT_CLASS (tuba_emoji_provider_proposal_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
tuba_emoji_provider_proposal_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TubaEmojiProviderProposalClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_emoji_provider_proposal_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaEmojiProviderProposal), 0, (GInstanceInitFunc) tuba_emoji_provider_proposal_instance_init, NULL };
	static const GInterfaceInfo gtk_source_completion_proposal_info = { (GInterfaceInitFunc) tuba_emoji_provider_proposal_gtk_source_completion_proposal_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType tuba_emoji_provider_proposal_type_id;
	tuba_emoji_provider_proposal_type_id = g_type_register_static (G_TYPE_OBJECT, "TubaEmojiProviderProposal", &g_define_type_info, G_TYPE_FLAG_NONE);
	g_type_add_interface_static (tuba_emoji_provider_proposal_type_id, gtk_source_completion_proposal_get_type (), &gtk_source_completion_proposal_info);
	TubaEmojiProviderProposal_private_offset = g_type_add_instance_private (tuba_emoji_provider_proposal_type_id, sizeof (TubaEmojiProviderProposalPrivate));
	return tuba_emoji_provider_proposal_type_id;
}

GType
tuba_emoji_provider_proposal_get_type (void)
{
	static GType tuba_emoji_provider_proposal_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_emoji_provider_proposal_type_id__once)) {
		GType tuba_emoji_provider_proposal_type_id;
		tuba_emoji_provider_proposal_type_id = tuba_emoji_provider_proposal_get_type_once ();
		g_once_init_leave_pointer (&tuba_emoji_provider_proposal_type_id__once, tuba_emoji_provider_proposal_type_id);
	}
	return tuba_emoji_provider_proposal_type_id__once;
}

static void
_vala_tuba_emoji_provider_proposal_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec)
{
	TubaEmojiProviderProposal * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL, TubaEmojiProviderProposal);
	switch (property_id) {
		case TUBA_EMOJI_PROVIDER_PROPOSAL_EMOJI_PROPERTY:
		g_value_set_object (value, tuba_emoji_provider_proposal_get_emoji (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tuba_emoji_provider_proposal_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec)
{
	TubaEmojiProviderProposal * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TUBA_EMOJI_PROVIDER_TYPE_PROPOSAL, TubaEmojiProviderProposal);
	switch (property_id) {
		case TUBA_EMOJI_PROVIDER_PROPOSAL_EMOJI_PROPERTY:
		tuba_emoji_provider_proposal_set_emoji (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
tuba_emoji_provider_class_init (TubaEmojiProviderClass * klass,
                                gpointer klass_data)
{
	tuba_emoji_provider_parent_class = g_type_class_peek_parent (klass);
	((TubaCompletionProviderClass *) klass)->suggest = (void (*) (TubaCompletionProvider*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) tuba_emoji_provider_real_suggest;
	((TubaCompletionProviderClass *) klass)->suggest_finish = (GListModel* (*) (TubaCompletionProvider*, GAsyncResult*, GError**)) tuba_emoji_provider_suggest_finish;
	((TubaCompletionProviderClass *) klass)->display = (void (*) (TubaCompletionProvider*, GtkSourceCompletionContext*, GtkSourceCompletionProposal*, GtkSourceCompletionCell*)) tuba_emoji_provider_real_display;
	((TubaCompletionProviderClass *) klass)->word_stop = (gboolean (*) (TubaCompletionProvider*, gunichar)) tuba_emoji_provider_real_word_stop;
}

static void
tuba_emoji_provider_instance_init (TubaEmojiProvider * self,
                                   gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
tuba_emoji_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TubaEmojiProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_emoji_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaEmojiProvider), 0, (GInstanceInitFunc) tuba_emoji_provider_instance_init, NULL };
	GType tuba_emoji_provider_type_id;
	tuba_emoji_provider_type_id = g_type_register_static (TUBA_TYPE_COMPLETION_PROVIDER, "TubaEmojiProvider", &g_define_type_info, G_TYPE_FLAG_NONE);
	return tuba_emoji_provider_type_id;
}

GType
tuba_emoji_provider_get_type (void)
{
	static GType tuba_emoji_provider_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_emoji_provider_type_id__once)) {
		GType tuba_emoji_provider_type_id;
		tuba_emoji_provider_type_id = tuba_emoji_provider_get_type_once ();
		g_once_init_leave_pointer (&tuba_emoji_provider_type_id__once, tuba_emoji_provider_type_id);
	}
	return tuba_emoji_provider_type_id__once;
}

