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

#include <glib-object.h>
#include <gtk/gtk.h>
#include "libdino.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>
#include "xmpp-vala.h"
#include "dino_i18n.h"
#include <pango/pango.h>
#include <gobject/gvaluecollector.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 DINO_UI_TYPE_GLOBAL_SEARCH (dino_ui_global_search_get_type ())
#define DINO_UI_GLOBAL_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_GLOBAL_SEARCH, DinoUiGlobalSearch))
#define DINO_UI_GLOBAL_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_GLOBAL_SEARCH, DinoUiGlobalSearchClass))
#define DINO_UI_IS_GLOBAL_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_GLOBAL_SEARCH))
#define DINO_UI_IS_GLOBAL_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_GLOBAL_SEARCH))
#define DINO_UI_GLOBAL_SEARCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_GLOBAL_SEARCH, DinoUiGlobalSearchClass))

typedef struct _DinoUiGlobalSearch DinoUiGlobalSearch;
typedef struct _DinoUiGlobalSearchClass DinoUiGlobalSearchClass;
typedef struct _DinoUiGlobalSearchPrivate DinoUiGlobalSearchPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block59Data Block59Data;
#define _dino_ui_global_search_unref0(var) ((var == NULL) ? NULL : (var = (dino_ui_global_search_unref (var), NULL)))

#define DINO_UI_TYPE_AVATAR_PICTURE (dino_ui_avatar_picture_get_type ())
#define DINO_UI_AVATAR_PICTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_AVATAR_PICTURE, DinoUiAvatarPicture))
#define DINO_UI_AVATAR_PICTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_AVATAR_PICTURE, DinoUiAvatarPictureClass))
#define DINO_UI_IS_AVATAR_PICTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_AVATAR_PICTURE))
#define DINO_UI_IS_AVATAR_PICTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_AVATAR_PICTURE))
#define DINO_UI_AVATAR_PICTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_AVATAR_PICTURE, DinoUiAvatarPictureClass))

typedef struct _DinoUiAvatarPicture DinoUiAvatarPicture;
typedef struct _DinoUiAvatarPictureClass DinoUiAvatarPictureClass;

#define DINO_UI_VIEW_MODEL_TYPE_AVATAR_PICTURE_MODEL (dino_ui_view_model_avatar_picture_model_get_type ())
#define DINO_UI_VIEW_MODEL_AVATAR_PICTURE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_VIEW_MODEL_TYPE_AVATAR_PICTURE_MODEL, DinoUiViewModelAvatarPictureModel))
#define DINO_UI_VIEW_MODEL_AVATAR_PICTURE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_VIEW_MODEL_TYPE_AVATAR_PICTURE_MODEL, DinoUiViewModelAvatarPictureModelClass))
#define DINO_UI_VIEW_MODEL_IS_AVATAR_PICTURE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_VIEW_MODEL_TYPE_AVATAR_PICTURE_MODEL))
#define DINO_UI_VIEW_MODEL_IS_AVATAR_PICTURE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_VIEW_MODEL_TYPE_AVATAR_PICTURE_MODEL))
#define DINO_UI_VIEW_MODEL_AVATAR_PICTURE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_VIEW_MODEL_TYPE_AVATAR_PICTURE_MODEL, DinoUiViewModelAvatarPictureModelClass))

typedef struct _DinoUiViewModelAvatarPictureModel DinoUiViewModelAvatarPictureModel;
typedef struct _DinoUiViewModelAvatarPictureModelClass DinoUiViewModelAvatarPictureModelClass;

#define DINO_UI_VIEW_MODEL_TYPE_COMPAT_AVATAR_PICTURE_MODEL (dino_ui_view_model_compat_avatar_picture_model_get_type ())
#define DINO_UI_VIEW_MODEL_COMPAT_AVATAR_PICTURE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_VIEW_MODEL_TYPE_COMPAT_AVATAR_PICTURE_MODEL, DinoUiViewModelCompatAvatarPictureModel))
#define DINO_UI_VIEW_MODEL_COMPAT_AVATAR_PICTURE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_VIEW_MODEL_TYPE_COMPAT_AVATAR_PICTURE_MODEL, DinoUiViewModelCompatAvatarPictureModelClass))
#define DINO_UI_VIEW_MODEL_IS_COMPAT_AVATAR_PICTURE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_VIEW_MODEL_TYPE_COMPAT_AVATAR_PICTURE_MODEL))
#define DINO_UI_VIEW_MODEL_IS_COMPAT_AVATAR_PICTURE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_VIEW_MODEL_TYPE_COMPAT_AVATAR_PICTURE_MODEL))
#define DINO_UI_VIEW_MODEL_COMPAT_AVATAR_PICTURE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_VIEW_MODEL_TYPE_COMPAT_AVATAR_PICTURE_MODEL, DinoUiViewModelCompatAvatarPictureModelClass))

typedef struct _DinoUiViewModelCompatAvatarPictureModel DinoUiViewModelCompatAvatarPictureModel;
typedef struct _DinoUiViewModelCompatAvatarPictureModelClass DinoUiViewModelCompatAvatarPictureModelClass;
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
typedef struct _Block60Data Block60Data;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL)))
#define _pango_attr_list_unref0(var) ((var == NULL) ? NULL : (var = (pango_attr_list_unref (var), NULL)))
typedef struct _DinoUiParamSpecGlobalSearch DinoUiParamSpecGlobalSearch;
enum  {
	DINO_UI_GLOBAL_SEARCH_SELECTED_ITEM_SIGNAL,
	DINO_UI_GLOBAL_SEARCH_NUM_SIGNALS
};
static guint dino_ui_global_search_signals[DINO_UI_GLOBAL_SEARCH_NUM_SIGNALS] = {0};

struct _DinoUiGlobalSearch {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DinoUiGlobalSearchPrivate * priv;
	GtkOverlay* overlay;
	GtkSearchEntry* search_entry;
	GtkLabel* entry_number_label;
	GtkScrolledWindow* results_scrolled;
	GtkBox* results_box;
	GtkStack* results_empty_stack;
	GtkFrame* auto_complete_overlay;
	GtkListBox* auto_complete_list;
};

struct _DinoUiGlobalSearchClass {
	GTypeClass parent_class;
	void (*finalize) (DinoUiGlobalSearch *self);
};

struct _DinoUiGlobalSearchPrivate {
	DinoStreamInteractor* stream_interactor;
	gchar* search;
	gint loaded_results;
	GMutex reloading_mutex;
	GeeArrayList* auto_complete_children;
	GeeArrayList* results_box_children;
};

struct _Block59Data {
	int _ref_count_;
	DinoUiGlobalSearch* self;
	DinoSearchSuggestion* suggestion;
};

struct _Block60Data {
	int _ref_count_;
	DinoUiGlobalSearch* self;
	DinoMessageItem* item;
};

struct _DinoUiParamSpecGlobalSearch {
	GParamSpec parent_instance;
};

static gint DinoUiGlobalSearch_private_offset;
static gpointer dino_ui_global_search_parent_class = NULL;

VALA_EXTERN gpointer dino_ui_global_search_ref (gpointer instance);
VALA_EXTERN void dino_ui_global_search_unref (gpointer instance);
VALA_EXTERN GParamSpec* dino_ui_param_spec_global_search (const gchar* name,
                                              const gchar* nick,
                                              const gchar* blurb,
                                              GType object_type,
                                              GParamFlags flags);
VALA_EXTERN void dino_ui_value_set_global_search (GValue* value,
                                      gpointer v_object);
VALA_EXTERN void dino_ui_value_take_global_search (GValue* value,
                                       gpointer v_object);
VALA_EXTERN gpointer dino_ui_value_get_global_search (const GValue* value);
VALA_EXTERN GType dino_ui_global_search_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiGlobalSearch, dino_ui_global_search_unref)
VALA_EXTERN DinoUiGlobalSearch* dino_ui_global_search_new (DinoStreamInteractor* stream_interactor);
VALA_EXTERN DinoUiGlobalSearch* dino_ui_global_search_construct (GType object_type,
                                                     DinoStreamInteractor* stream_interactor);
static void __lambda152_ (DinoUiGlobalSearch* self);
static void dino_ui_global_search_set_search (DinoUiGlobalSearch* self,
                                       const gchar* search);
static void ___lambda152__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                    gpointer self);
static void dino_ui_global_search_update_auto_complete (DinoUiGlobalSearch* self);
static void _dino_ui_global_search_update_auto_complete_g_object_notify (GObject* _sender,
                                                                  GParamSpec* pspec,
                                                                  gpointer self);
static void dino_ui_global_search_on_scrolled_window_vadjustment_value (DinoUiGlobalSearch* self);
static void _dino_ui_global_search_on_scrolled_window_vadjustment_value_g_object_notify (GObject* _sender,
                                                                                  GParamSpec* pspec,
                                                                                  gpointer self);
static void dino_ui_global_search_on_scrolled_window_vadjustment_upper (DinoUiGlobalSearch* self);
static void _dino_ui_global_search_on_scrolled_window_vadjustment_upper_g_object_notify (GObject* _sender,
                                                                                  GParamSpec* pspec,
                                                                                  gpointer self);
static gboolean dino_ui_global_search_on_key_pressed (DinoUiGlobalSearch* self,
                                               guint keyval,
                                               guint keycode,
                                               GdkModifierType state);
static gboolean _dino_ui_global_search_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                     guint keyval,
                                                                                     guint keycode,
                                                                                     GdkModifierType state,
                                                                                     gpointer self);
static void dino_ui_global_search_on_key_released (DinoUiGlobalSearch* self,
                                            guint keyval,
                                            guint keycode,
                                            GdkModifierType state);
static void _dino_ui_global_search_on_key_released_gtk_event_controller_key_key_released (GtkEventControllerKey* _sender,
                                                                                   guint keyval,
                                                                                   guint keycode,
                                                                                   GdkModifierType state,
                                                                                   gpointer self);
static void dino_ui_global_search_append_messages (DinoUiGlobalSearch* self,
                                            GeeList* messages);
static Block59Data* block59_data_ref (Block59Data* _data59_);
static void block59_data_unref (void * _userdata_);
VALA_EXTERN GType dino_ui_avatar_picture_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiAvatarPicture, g_object_unref)
VALA_EXTERN gchar* dino_ui_util_get_participant_display_name (DinoStreamInteractor* stream_interactor,
                                                  DinoEntitiesConversation* conversation,
                                                  XmppJid* participant,
                                                  gboolean me_is_me);
VALA_EXTERN DinoUiViewModelCompatAvatarPictureModel* dino_ui_view_model_compat_avatar_picture_model_new (DinoStreamInteractor* stream_interactor);
VALA_EXTERN DinoUiViewModelCompatAvatarPictureModel* dino_ui_view_model_compat_avatar_picture_model_construct (GType object_type,
                                                                                                   DinoStreamInteractor* stream_interactor);
VALA_EXTERN GType dino_ui_view_model_avatar_picture_model_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiViewModelAvatarPictureModel, g_object_unref)
VALA_EXTERN GType dino_ui_view_model_compat_avatar_picture_model_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiViewModelCompatAvatarPictureModel, g_object_unref)
VALA_EXTERN DinoUiViewModelCompatAvatarPictureModel* dino_ui_view_model_compat_avatar_picture_model_add_participant (DinoUiViewModelCompatAvatarPictureModel* self,
                                                                                                         DinoEntitiesConversation* conversation,
                                                                                                         XmppJid* jid);
VALA_EXTERN void dino_ui_avatar_picture_set_model (DinoUiAvatarPicture* self,
                                       DinoUiViewModelAvatarPictureModel* value);
VALA_EXTERN gchar* dino_ui_util_get_conversation_display_name (DinoStreamInteractor* stream_interactor,
                                                   DinoEntitiesConversation* conversation);
VALA_EXTERN DinoUiViewModelCompatAvatarPictureModel* dino_ui_view_model_compat_avatar_picture_model_set_conversation (DinoUiViewModelCompatAvatarPictureModel* self,
                                                                                                          DinoEntitiesConversation* conversation);
static void _____lambda154_ (Block59Data* _data59_);
static void dino_ui_global_search_handle_suggestion (DinoUiGlobalSearch* self,
                                              DinoSearchSuggestion* suggestion);
static void ______lambda154__gtk_list_box_row_activate (GtkListBoxRow* _sender,
                                                 gpointer self);
static void dino_ui_global_search_clear_search (DinoUiGlobalSearch* self);
static GeeList* dino_ui_global_search_get_keywords (const gchar* search_string);
static GtkGrid* dino_ui_global_search_get_context_message_widget (DinoUiGlobalSearch* self,
                                                           DinoMessageItem* item);
static GtkWidget* dino_ui_global_search_get_match_message_widget (DinoUiGlobalSearch* self,
                                                           DinoMessageItem* item);
VALA_EXTERN gchar* dino_ui_conversation_summary_conversation_item_skeleton_get_relative_time (GDateTime* datetime);
static Block60Data* block60_data_ref (Block60Data* _data60_);
static void block60_data_unref (void * _userdata_);
static GtkGrid* dino_ui_global_search_get_skeleton (DinoUiGlobalSearch* self,
                                             DinoMessageItem* item);
VALA_EXTERN gchar* dino_ui_util_unbreak_space_around_non_spacing_mark (gchar* s);
VALA_EXTERN gboolean dino_ui_util_is_dark_theme (GtkWidget* widget);
static void __lambda153_ (Block60Data* _data60_);
static void ___lambda153__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN DinoUiAvatarPicture* dino_ui_avatar_picture_new (void);
VALA_EXTERN DinoUiAvatarPicture* dino_ui_avatar_picture_construct (GType object_type);
VALA_EXTERN GtkWidget* dino_ui_global_search_get_widget (DinoUiGlobalSearch* self);
static void dino_ui_global_search_finalize (DinoUiGlobalSearch * obj);
static GType dino_ui_global_search_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 gssize _vala_array_length (gpointer array);
static void _vala_clear_GMutex (GMutex * mutex);
static void _vala_clear_GRecMutex (GRecMutex * mutex);
static void _vala_clear_GRWLock (GRWLock * mutex);
static void _vala_clear_GCond (GCond * mutex);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_ui_global_search_get_instance_private (DinoUiGlobalSearch* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiGlobalSearch_private_offset);
}

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

static void
__lambda152_ (DinoUiGlobalSearch* self)
{
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	_tmp0_ = self->search_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = _tmp1_;
	dino_ui_global_search_set_search (self, _tmp2_);
}

static void
___lambda152__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                               gpointer self)
{
	__lambda152_ ((DinoUiGlobalSearch*) self);
}

static void
_dino_ui_global_search_update_auto_complete_g_object_notify (GObject* _sender,
                                                             GParamSpec* pspec,
                                                             gpointer self)
{
	dino_ui_global_search_update_auto_complete ((DinoUiGlobalSearch*) self);
}

static void
_dino_ui_global_search_on_scrolled_window_vadjustment_value_g_object_notify (GObject* _sender,
                                                                             GParamSpec* pspec,
                                                                             gpointer self)
{
	dino_ui_global_search_on_scrolled_window_vadjustment_value ((DinoUiGlobalSearch*) self);
}

static void
_dino_ui_global_search_on_scrolled_window_vadjustment_upper_g_object_notify (GObject* _sender,
                                                                             GParamSpec* pspec,
                                                                             gpointer self)
{
	dino_ui_global_search_on_scrolled_window_vadjustment_upper ((DinoUiGlobalSearch*) self);
}

static gboolean
_dino_ui_global_search_on_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                            guint keyval,
                                                                            guint keycode,
                                                                            GdkModifierType state,
                                                                            gpointer self)
{
	gboolean result;
	result = dino_ui_global_search_on_key_pressed ((DinoUiGlobalSearch*) self, keyval, keycode, state);
	return result;
}

static void
_dino_ui_global_search_on_key_released_gtk_event_controller_key_key_released (GtkEventControllerKey* _sender,
                                                                              guint keyval,
                                                                              guint keycode,
                                                                              GdkModifierType state,
                                                                              gpointer self)
{
	dino_ui_global_search_on_key_released ((DinoUiGlobalSearch*) self, keyval, keycode, state);
}

DinoUiGlobalSearch*
dino_ui_global_search_construct (GType object_type,
                                 DinoStreamInteractor* stream_interactor)
{
	DinoUiGlobalSearch* self = NULL;
	DinoStreamInteractor* _tmp0_;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp1_;
	GObject* _tmp2_;
	GtkOverlay* _tmp3_;
	GObject* _tmp4_;
	GtkSearchEntry* _tmp5_;
	GObject* _tmp6_;
	GtkLabel* _tmp7_;
	GObject* _tmp8_;
	GtkScrolledWindow* _tmp9_;
	GObject* _tmp10_;
	GtkBox* _tmp11_;
	GObject* _tmp12_;
	GtkStack* _tmp13_;
	GObject* _tmp14_;
	GtkFrame* _tmp15_;
	GObject* _tmp16_;
	GtkListBox* _tmp17_;
	GtkSearchEntry* _tmp18_;
	GtkSearchEntry* _tmp19_;
	GtkSearchEntry* _tmp20_;
	GtkScrolledWindow* _tmp21_;
	GtkAdjustment* _tmp22_;
	GtkAdjustment* _tmp23_;
	GtkScrolledWindow* _tmp24_;
	GtkAdjustment* _tmp25_;
	GtkAdjustment* _tmp26_;
	GtkEventControllerKey* overlay_key_events = NULL;
	gchar* _tmp27_;
	GtkEventControllerKey* _tmp28_ = NULL;
	GtkOverlay* _tmp29_;
	GtkEventController* _tmp30_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	self = (DinoUiGlobalSearch*) g_type_create_instance (object_type);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	_tmp1_ = gtk_builder_new_from_resource ("/im/dino/Dino/global_search.ui");
	builder = _tmp1_;
	_tmp2_ = gtk_builder_get_object (builder, "overlay");
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_overlay_get_type (), GtkOverlay));
	_g_object_unref0 (self->overlay);
	self->overlay = _tmp3_;
	_tmp4_ = gtk_builder_get_object (builder, "search_entry");
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_search_entry_get_type (), GtkSearchEntry));
	_g_object_unref0 (self->search_entry);
	self->search_entry = _tmp5_;
	_tmp6_ = gtk_builder_get_object (builder, "entry_number_label");
	_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_label_get_type (), GtkLabel));
	_g_object_unref0 (self->entry_number_label);
	self->entry_number_label = _tmp7_;
	_tmp8_ = gtk_builder_get_object (builder, "results_scrolled");
	_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_scrolled_window_get_type (), GtkScrolledWindow));
	_g_object_unref0 (self->results_scrolled);
	self->results_scrolled = _tmp9_;
	_tmp10_ = gtk_builder_get_object (builder, "results_box");
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_box_get_type (), GtkBox));
	_g_object_unref0 (self->results_box);
	self->results_box = _tmp11_;
	_tmp12_ = gtk_builder_get_object (builder, "results_empty_stack");
	_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_stack_get_type (), GtkStack));
	_g_object_unref0 (self->results_empty_stack);
	self->results_empty_stack = _tmp13_;
	_tmp14_ = gtk_builder_get_object (builder, "auto_complete_overlay");
	_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_frame_get_type (), GtkFrame));
	_g_object_unref0 (self->auto_complete_overlay);
	self->auto_complete_overlay = _tmp15_;
	_tmp16_ = gtk_builder_get_object (builder, "auto_complete_list");
	_tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_list_box_get_type (), GtkListBox));
	_g_object_unref0 (self->auto_complete_list);
	self->auto_complete_list = _tmp17_;
	_tmp18_ = self->search_entry;
	g_signal_connect (_tmp18_, "search-changed", (GCallback) ___lambda152__gtk_search_entry_search_changed, self);
	_tmp19_ = self->search_entry;
	g_signal_connect_after ((GObject*) _tmp19_, "notify::text", (GCallback) _dino_ui_global_search_update_auto_complete_g_object_notify, self);
	_tmp20_ = self->search_entry;
	g_signal_connect_after ((GObject*) _tmp20_, "notify::cursor-position", (GCallback) _dino_ui_global_search_update_auto_complete_g_object_notify, self);
	_tmp21_ = self->results_scrolled;
	_tmp22_ = gtk_scrolled_window_get_vadjustment (_tmp21_);
	_tmp23_ = _tmp22_;
	g_signal_connect ((GObject*) _tmp23_, "notify::value", (GCallback) _dino_ui_global_search_on_scrolled_window_vadjustment_value_g_object_notify, self);
	_tmp24_ = self->results_scrolled;
	_tmp25_ = gtk_scrolled_window_get_vadjustment (_tmp24_);
	_tmp26_ = _tmp25_;
	g_signal_connect_after ((GObject*) _tmp26_, "notify::upper", (GCallback) _dino_ui_global_search_on_scrolled_window_vadjustment_upper_g_object_notify, self);
	_tmp27_ = g_strdup ("dino-search-overlay-key-events");
	_tmp28_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	gtk_event_controller_set_name ((GtkEventController*) _tmp28_, _tmp27_);
	_g_free0 (_tmp27_);
	overlay_key_events = _tmp28_;
	g_signal_connect (overlay_key_events, "key-pressed", (GCallback) _dino_ui_global_search_on_key_pressed_gtk_event_controller_key_key_pressed, self);
	g_signal_connect (overlay_key_events, "key-released", (GCallback) _dino_ui_global_search_on_key_released_gtk_event_controller_key_key_released, self);
	_tmp29_ = self->overlay;
	_tmp30_ = _g_object_ref0 ((GtkEventController*) overlay_key_events);
	gtk_widget_add_controller ((GtkWidget*) _tmp29_, _tmp30_);
	_g_object_unref0 (overlay_key_events);
	_g_object_unref0 (builder);
	return self;
}

DinoUiGlobalSearch*
dino_ui_global_search_new (DinoStreamInteractor* stream_interactor)
{
	return dino_ui_global_search_construct (DINO_UI_TYPE_GLOBAL_SEARCH, stream_interactor);
}

static void
dino_ui_global_search_on_scrolled_window_vadjustment_value (DinoUiGlobalSearch* self)
{
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	gdouble _tmp3_;
	gdouble _tmp4_;
	GtkScrolledWindow* _tmp5_;
	GtkAdjustment* _tmp6_;
	GtkAdjustment* _tmp7_;
	gdouble _tmp8_;
	gdouble _tmp9_;
	GtkScrolledWindow* _tmp10_;
	GtkAdjustment* _tmp11_;
	GtkAdjustment* _tmp12_;
	gdouble _tmp13_;
	gdouble _tmp14_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->results_scrolled;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_adjustment_get_upper (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->results_scrolled;
	_tmp6_ = gtk_scrolled_window_get_vadjustment (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = gtk_adjustment_get_value (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = self->results_scrolled;
	_tmp11_ = gtk_scrolled_window_get_vadjustment (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = gtk_adjustment_get_page_size (_tmp12_);
	_tmp14_ = _tmp13_;
	if ((_tmp4_ - (_tmp9_ + _tmp14_)) < ((gdouble) 100)) {
		GeeList* new_messages = NULL;
		DinoStreamInteractor* _tmp15_;
		DinoModuleIdentity* _tmp16_;
		gpointer _tmp17_;
		DinoSearchProcessor* _tmp18_;
		const gchar* _tmp19_;
		GeeList* _tmp20_;
		GeeList* _tmp21_;
		GeeList* _tmp22_;
		gint _tmp23_;
		gint _tmp24_;
		GeeList* _tmp25_;
		gint _tmp26_;
		gint _tmp27_;
		GeeList* _tmp28_;
		if (!g_mutex_trylock (&self->priv->reloading_mutex)) {
			return;
		}
		_tmp15_ = self->priv->stream_interactor;
		_tmp16_ = dino_search_processor_IDENTITY;
		_tmp17_ = dino_stream_interactor_get_module (_tmp15_, DINO_TYPE_SEARCH_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp16_);
		_tmp18_ = (DinoSearchProcessor*) _tmp17_;
		_tmp19_ = self->priv->search;
		_tmp20_ = dino_search_processor_match_messages (_tmp18_, _tmp19_, self->priv->loaded_results);
		_tmp21_ = _tmp20_;
		_g_object_unref0 (_tmp18_);
		new_messages = _tmp21_;
		_tmp22_ = new_messages;
		_tmp23_ = gee_collection_get_size ((GeeCollection*) _tmp22_);
		_tmp24_ = _tmp23_;
		if (_tmp24_ == 0) {
			g_mutex_unlock (&self->priv->reloading_mutex);
			_g_object_unref0 (new_messages);
			return;
		}
		_tmp25_ = new_messages;
		_tmp26_ = gee_collection_get_size ((GeeCollection*) _tmp25_);
		_tmp27_ = _tmp26_;
		self->priv->loaded_results = self->priv->loaded_results + _tmp27_;
		_tmp28_ = new_messages;
		dino_ui_global_search_append_messages (self, _tmp28_);
		_g_object_unref0 (new_messages);
	}
}

static void
dino_ui_global_search_on_scrolled_window_vadjustment_upper (DinoUiGlobalSearch* self)
{
	g_return_if_fail (self != NULL);
	g_mutex_trylock (&self->priv->reloading_mutex);
	g_mutex_unlock (&self->priv->reloading_mutex);
}

static gboolean
dino_ui_global_search_on_key_pressed (DinoUiGlobalSearch* self,
                                      guint keyval,
                                      guint keycode,
                                      GdkModifierType state)
{
	GtkFrame* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->auto_complete_overlay;
	_tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		result = FALSE;
		return result;
	}
	if (keyval == GDK_KEY_Up) {
		GtkListBoxRow* row = NULL;
		GtkListBox* _tmp3_;
		GtkListBoxRow* _tmp4_;
		GtkListBoxRow* _tmp5_;
		gint _tmp6_ = 0;
		GtkListBoxRow* _tmp7_;
		gint index = 0;
		GtkListBox* _tmp12_;
		GtkListBox* _tmp13_;
		GtkListBoxRow* _tmp14_;
		_tmp3_ = self->auto_complete_list;
		_tmp4_ = gtk_list_box_get_selected_row (_tmp3_);
		_tmp5_ = _g_object_ref0 (_tmp4_);
		row = _tmp5_;
		_tmp7_ = row;
		if (_tmp7_ == NULL) {
			_tmp6_ = -1;
		} else {
			GtkListBoxRow* _tmp8_;
			_tmp8_ = row;
			_tmp6_ = gtk_list_box_row_get_index (_tmp8_) - 1;
		}
		index = _tmp6_;
		if (index == -1) {
			GeeArrayList* _tmp9_;
			gint _tmp10_;
			gint _tmp11_;
			_tmp9_ = self->priv->auto_complete_children;
			_tmp10_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp9_);
			_tmp11_ = _tmp10_;
			index = ((gint) _tmp11_) - 1;
		}
		_tmp12_ = self->auto_complete_list;
		_tmp13_ = self->auto_complete_list;
		_tmp14_ = gtk_list_box_get_row_at_index (_tmp13_, index);
		gtk_list_box_select_row (_tmp12_, _tmp14_);
		result = TRUE;
		_g_object_unref0 (row);
		return result;
	}
	if (keyval == GDK_KEY_Down) {
		GtkListBoxRow* row = NULL;
		GtkListBox* _tmp15_;
		GtkListBoxRow* _tmp16_;
		GtkListBoxRow* _tmp17_;
		gint _tmp18_ = 0;
		GtkListBoxRow* _tmp19_;
		gint index = 0;
		GeeArrayList* _tmp21_;
		gint _tmp22_;
		gint _tmp23_;
		GtkListBox* _tmp24_;
		GtkListBox* _tmp25_;
		GtkListBoxRow* _tmp26_;
		_tmp15_ = self->auto_complete_list;
		_tmp16_ = gtk_list_box_get_selected_row (_tmp15_);
		_tmp17_ = _g_object_ref0 (_tmp16_);
		row = _tmp17_;
		_tmp19_ = row;
		if (_tmp19_ == NULL) {
			_tmp18_ = 0;
		} else {
			GtkListBoxRow* _tmp20_;
			_tmp20_ = row;
			_tmp18_ = gtk_list_box_row_get_index (_tmp20_) + 1;
		}
		index = _tmp18_;
		_tmp21_ = self->priv->auto_complete_children;
		_tmp22_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp21_);
		_tmp23_ = _tmp22_;
		if (index == _tmp23_) {
			index = 0;
		}
		_tmp24_ = self->auto_complete_list;
		_tmp25_ = self->auto_complete_list;
		_tmp26_ = gtk_list_box_get_row_at_index (_tmp25_, index);
		gtk_list_box_select_row (_tmp24_, _tmp26_);
		result = TRUE;
		_g_object_unref0 (row);
		return result;
	}
	if (keyval == GDK_KEY_Tab) {
		GtkListBox* _tmp27_;
		GtkListBoxRow* _tmp28_;
		_tmp27_ = self->auto_complete_list;
		_tmp28_ = gtk_list_box_get_selected_row (_tmp27_);
		g_signal_emit_by_name (_tmp28_, "activate");
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static void
dino_ui_global_search_on_key_released (DinoUiGlobalSearch* self,
                                       guint keyval,
                                       guint keycode,
                                       GdkModifierType state)
{
	GtkFrame* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->auto_complete_overlay;
	_tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		return;
	}
	if (keyval == GDK_KEY_Return) {
		GtkListBox* _tmp3_;
		GtkListBoxRow* _tmp4_;
		_tmp3_ = self->auto_complete_list;
		_tmp4_ = gtk_list_box_get_selected_row (_tmp3_);
		g_signal_emit_by_name (_tmp4_, "activate");
	}
}

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

static void
block59_data_unref (void * _userdata_)
{
	Block59Data* _data59_;
	_data59_ = (Block59Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data59_->_ref_count_)) {
		DinoUiGlobalSearch* self;
		self = _data59_->self;
		_g_object_unref0 (_data59_->suggestion);
		_dino_ui_global_search_unref0 (self);
		g_slice_free (Block59Data, _data59_);
	}
}

static void
_____lambda154_ (Block59Data* _data59_)
{
	DinoUiGlobalSearch* self;
	DinoSearchSuggestion* _tmp0_;
	self = _data59_->self;
	_tmp0_ = _data59_->suggestion;
	dino_ui_global_search_handle_suggestion (self, _tmp0_);
}

static void
______lambda154__gtk_list_box_row_activate (GtkListBoxRow* _sender,
                                            gpointer self)
{
	_____lambda154_ (self);
}

static void
dino_ui_global_search_update_auto_complete (DinoUiGlobalSearch* self)
{
	GeeList* suggestions = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoSearchProcessor* _tmp3_;
	GtkSearchEntry* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	GtkSearchEntry* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	GeeList* _tmp10_;
	GeeList* _tmp11_;
	GtkFrame* _tmp12_;
	GeeList* _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	GeeList* _tmp16_;
	gint _tmp17_;
	gint _tmp18_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_search_processor_IDENTITY;
	_tmp2_ = dino_stream_interactor_get_module (_tmp0_, DINO_TYPE_SEARCH_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (DinoSearchProcessor*) _tmp2_;
	_tmp4_ = self->search_entry;
	_tmp5_ = gtk_editable_get_text ((GtkEditable*) _tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->search_entry;
	g_object_get ((GtkEditable*) _tmp7_, "cursor-position", &_tmp8_, NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = dino_search_processor_suggest_auto_complete (_tmp3_, _tmp6_, _tmp9_, 5);
	_tmp11_ = _tmp10_;
	_g_object_unref0 (_tmp3_);
	suggestions = _tmp11_;
	_tmp12_ = self->auto_complete_overlay;
	_tmp13_ = suggestions;
	_tmp14_ = gee_collection_get_size ((GeeCollection*) _tmp13_);
	_tmp15_ = _tmp14_;
	gtk_widget_set_visible ((GtkWidget*) _tmp12_, _tmp15_ > 0);
	_tmp16_ = suggestions;
	_tmp17_ = gee_collection_get_size ((GeeCollection*) _tmp16_);
	_tmp18_ = _tmp17_;
	if (_tmp18_ > 0) {
		GeeArrayList* _tmp29_;
		GtkListBox* _tmp130_;
		GtkListBox* _tmp131_;
		GtkListBoxRow* _tmp132_;
		{
			GeeArrayList* _widget_list = NULL;
			GeeArrayList* _tmp19_;
			gint _widget_size = 0;
			GeeArrayList* _tmp20_;
			gint _tmp21_;
			gint _tmp22_;
			gint _widget_index = 0;
			_tmp19_ = self->priv->auto_complete_children;
			_widget_list = _tmp19_;
			_tmp20_ = _widget_list;
			_tmp21_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp20_);
			_tmp22_ = _tmp21_;
			_widget_size = _tmp22_;
			_widget_index = -1;
			while (TRUE) {
				gint _tmp23_;
				gint _tmp24_;
				GtkWidget* widget = NULL;
				GeeArrayList* _tmp25_;
				gpointer _tmp26_;
				GtkListBox* _tmp27_;
				GtkWidget* _tmp28_;
				_widget_index = _widget_index + 1;
				_tmp23_ = _widget_index;
				_tmp24_ = _widget_size;
				if (!(_tmp23_ < _tmp24_)) {
					break;
				}
				_tmp25_ = _widget_list;
				_tmp26_ = gee_abstract_list_get ((GeeAbstractList*) _tmp25_, _widget_index);
				widget = (GtkWidget*) _tmp26_;
				_tmp27_ = self->auto_complete_list;
				_tmp28_ = widget;
				gtk_list_box_remove (_tmp27_, _tmp28_);
				_g_object_unref0 (widget);
			}
		}
		_tmp29_ = self->priv->auto_complete_children;
		gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp29_);
		{
			GeeList* _suggestion_list = NULL;
			GeeList* _tmp30_;
			gint _suggestion_size = 0;
			GeeList* _tmp31_;
			gint _tmp32_;
			gint _tmp33_;
			gint _suggestion_index = 0;
			_tmp30_ = suggestions;
			_suggestion_list = _tmp30_;
			_tmp31_ = _suggestion_list;
			_tmp32_ = gee_collection_get_size ((GeeCollection*) _tmp31_);
			_tmp33_ = _tmp32_;
			_suggestion_size = _tmp33_;
			_suggestion_index = -1;
			while (TRUE) {
				Block59Data* _data59_;
				gint _tmp34_;
				gint _tmp35_;
				GeeList* _tmp36_;
				gpointer _tmp37_;
				GtkBuilder* builder = NULL;
				GtkBuilder* _tmp38_;
				DinoUiAvatarPicture* avatar = NULL;
				GtkBuilder* _tmp39_;
				GObject* _tmp40_;
				DinoUiAvatarPicture* _tmp41_;
				GtkLabel* label = NULL;
				GtkBuilder* _tmp42_;
				GObject* _tmp43_;
				GtkLabel* _tmp44_;
				gchar* display_name = NULL;
				gboolean _tmp45_ = FALSE;
				gboolean _tmp46_ = FALSE;
				DinoSearchSuggestion* _tmp47_;
				DinoEntitiesConversation* _tmp48_;
				DinoEntitiesConversation* _tmp49_;
				DinoEntitiesConversationType _tmp50_;
				DinoEntitiesConversationType _tmp51_;
				const gchar* _tmp99_;
				DinoSearchSuggestion* _tmp100_;
				XmppJid* _tmp101_;
				XmppJid* _tmp102_;
				gchar* _tmp103_;
				gchar* _tmp104_;
				gboolean _tmp105_;
				GtkListBoxRow* row = NULL;
				GtkListBoxRow* _tmp121_ = NULL;
				GtkListBoxRow* _tmp122_;
				GtkBuilder* _tmp123_;
				GObject* _tmp124_;
				GtkListBoxRow* _tmp125_;
				GtkListBox* _tmp126_;
				GtkListBoxRow* _tmp127_;
				GeeArrayList* _tmp128_;
				GtkListBoxRow* _tmp129_;
				_data59_ = g_slice_new0 (Block59Data);
				_data59_->_ref_count_ = 1;
				_data59_->self = dino_ui_global_search_ref (self);
				_suggestion_index = _suggestion_index + 1;
				_tmp34_ = _suggestion_index;
				_tmp35_ = _suggestion_size;
				if (!(_tmp34_ < _tmp35_)) {
					block59_data_unref (_data59_);
					_data59_ = NULL;
					break;
				}
				_tmp36_ = _suggestion_list;
				_tmp37_ = gee_list_get (_tmp36_, _suggestion_index);
				_data59_->suggestion = (DinoSearchSuggestion*) _tmp37_;
				_tmp38_ = gtk_builder_new_from_resource ("/im/dino/Dino/search_autocomplete.ui");
				builder = _tmp38_;
				_tmp39_ = builder;
				_tmp40_ = gtk_builder_get_object (_tmp39_, "picture");
				_tmp41_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp40_, DINO_UI_TYPE_AVATAR_PICTURE, DinoUiAvatarPicture));
				avatar = _tmp41_;
				_tmp42_ = builder;
				_tmp43_ = gtk_builder_get_object (_tmp42_, "label");
				_tmp44_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, gtk_label_get_type (), GtkLabel));
				label = _tmp44_;
				_tmp47_ = _data59_->suggestion;
				_tmp48_ = dino_search_suggestion_get_conversation (_tmp47_);
				_tmp49_ = _tmp48_;
				_tmp50_ = dino_entities_conversation_get_type_ (_tmp49_);
				_tmp51_ = _tmp50_;
				if (_tmp51_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT) {
					DinoSearchSuggestion* _tmp52_;
					DinoEntitiesConversation* _tmp53_;
					DinoEntitiesConversation* _tmp54_;
					XmppJid* _tmp55_;
					XmppJid* _tmp56_;
					DinoSearchSuggestion* _tmp57_;
					XmppJid* _tmp58_;
					XmppJid* _tmp59_;
					_tmp52_ = _data59_->suggestion;
					_tmp53_ = dino_search_suggestion_get_conversation (_tmp52_);
					_tmp54_ = _tmp53_;
					_tmp55_ = dino_entities_conversation_get_counterpart (_tmp54_);
					_tmp56_ = _tmp55_;
					_tmp57_ = _data59_->suggestion;
					_tmp58_ = dino_search_suggestion_get_jid (_tmp57_);
					_tmp59_ = _tmp58_;
					_tmp46_ = !xmpp_jid_equals (_tmp56_, _tmp59_);
				} else {
					_tmp46_ = FALSE;
				}
				if (_tmp46_) {
					_tmp45_ = TRUE;
				} else {
					DinoSearchSuggestion* _tmp60_;
					DinoEntitiesConversation* _tmp61_;
					DinoEntitiesConversation* _tmp62_;
					DinoEntitiesConversationType _tmp63_;
					DinoEntitiesConversationType _tmp64_;
					_tmp60_ = _data59_->suggestion;
					_tmp61_ = dino_search_suggestion_get_conversation (_tmp60_);
					_tmp62_ = _tmp61_;
					_tmp63_ = dino_entities_conversation_get_type_ (_tmp62_);
					_tmp64_ = _tmp63_;
					_tmp45_ = _tmp64_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT_PM;
				}
				if (_tmp45_) {
					DinoStreamInteractor* _tmp65_;
					DinoSearchSuggestion* _tmp66_;
					DinoEntitiesConversation* _tmp67_;
					DinoEntitiesConversation* _tmp68_;
					DinoSearchSuggestion* _tmp69_;
					XmppJid* _tmp70_;
					XmppJid* _tmp71_;
					gchar* _tmp72_;
					DinoUiAvatarPicture* _tmp73_;
					DinoStreamInteractor* _tmp74_;
					DinoUiViewModelCompatAvatarPictureModel* _tmp75_;
					DinoUiViewModelCompatAvatarPictureModel* _tmp76_;
					DinoSearchSuggestion* _tmp77_;
					DinoEntitiesConversation* _tmp78_;
					DinoEntitiesConversation* _tmp79_;
					DinoSearchSuggestion* _tmp80_;
					XmppJid* _tmp81_;
					XmppJid* _tmp82_;
					DinoUiViewModelCompatAvatarPictureModel* _tmp83_;
					DinoUiViewModelCompatAvatarPictureModel* _tmp84_;
					_tmp65_ = self->priv->stream_interactor;
					_tmp66_ = _data59_->suggestion;
					_tmp67_ = dino_search_suggestion_get_conversation (_tmp66_);
					_tmp68_ = _tmp67_;
					_tmp69_ = _data59_->suggestion;
					_tmp70_ = dino_search_suggestion_get_jid (_tmp69_);
					_tmp71_ = _tmp70_;
					_tmp72_ = dino_ui_util_get_participant_display_name (_tmp65_, _tmp68_, _tmp71_, FALSE);
					_g_free0 (display_name);
					display_name = _tmp72_;
					_tmp73_ = avatar;
					_tmp74_ = self->priv->stream_interactor;
					_tmp75_ = dino_ui_view_model_compat_avatar_picture_model_new (_tmp74_);
					_tmp76_ = _tmp75_;
					_tmp77_ = _data59_->suggestion;
					_tmp78_ = dino_search_suggestion_get_conversation (_tmp77_);
					_tmp79_ = _tmp78_;
					_tmp80_ = _data59_->suggestion;
					_tmp81_ = dino_search_suggestion_get_jid (_tmp80_);
					_tmp82_ = _tmp81_;
					_tmp83_ = dino_ui_view_model_compat_avatar_picture_model_add_participant (_tmp76_, _tmp79_, _tmp82_);
					_tmp84_ = _tmp83_;
					dino_ui_avatar_picture_set_model (_tmp73_, (DinoUiViewModelAvatarPictureModel*) _tmp84_);
					_g_object_unref0 (_tmp84_);
					_g_object_unref0 (_tmp76_);
				} else {
					DinoStreamInteractor* _tmp85_;
					DinoSearchSuggestion* _tmp86_;
					DinoEntitiesConversation* _tmp87_;
					DinoEntitiesConversation* _tmp88_;
					gchar* _tmp89_;
					DinoUiAvatarPicture* _tmp90_;
					DinoStreamInteractor* _tmp91_;
					DinoUiViewModelCompatAvatarPictureModel* _tmp92_;
					DinoUiViewModelCompatAvatarPictureModel* _tmp93_;
					DinoSearchSuggestion* _tmp94_;
					DinoEntitiesConversation* _tmp95_;
					DinoEntitiesConversation* _tmp96_;
					DinoUiViewModelCompatAvatarPictureModel* _tmp97_;
					DinoUiViewModelCompatAvatarPictureModel* _tmp98_;
					_tmp85_ = self->priv->stream_interactor;
					_tmp86_ = _data59_->suggestion;
					_tmp87_ = dino_search_suggestion_get_conversation (_tmp86_);
					_tmp88_ = _tmp87_;
					_tmp89_ = dino_ui_util_get_conversation_display_name (_tmp85_, _tmp88_);
					_g_free0 (display_name);
					display_name = _tmp89_;
					_tmp90_ = avatar;
					_tmp91_ = self->priv->stream_interactor;
					_tmp92_ = dino_ui_view_model_compat_avatar_picture_model_new (_tmp91_);
					_tmp93_ = _tmp92_;
					_tmp94_ = _data59_->suggestion;
					_tmp95_ = dino_search_suggestion_get_conversation (_tmp94_);
					_tmp96_ = _tmp95_;
					_tmp97_ = dino_ui_view_model_compat_avatar_picture_model_set_conversation (_tmp93_, _tmp96_);
					_tmp98_ = _tmp97_;
					dino_ui_avatar_picture_set_model (_tmp90_, (DinoUiViewModelAvatarPictureModel*) _tmp98_);
					_g_object_unref0 (_tmp98_);
					_g_object_unref0 (_tmp93_);
				}
				_tmp99_ = display_name;
				_tmp100_ = _data59_->suggestion;
				_tmp101_ = dino_search_suggestion_get_jid (_tmp100_);
				_tmp102_ = _tmp101_;
				_tmp103_ = xmpp_jid_to_string (_tmp102_);
				_tmp104_ = _tmp103_;
				_tmp105_ = g_strcmp0 (_tmp99_, _tmp104_) != 0;
				_g_free0 (_tmp104_);
				if (_tmp105_) {
					GtkLabel* _tmp106_;
					const gchar* _tmp107_;
					gchar* _tmp108_;
					gchar* _tmp109_;
					DinoSearchSuggestion* _tmp110_;
					XmppJid* _tmp111_;
					XmppJid* _tmp112_;
					gchar* _tmp113_;
					gchar* _tmp114_;
					gchar* _tmp115_;
					gchar* _tmp116_;
					gchar* _tmp117_;
					gchar* _tmp118_;
					_tmp106_ = label;
					_tmp107_ = display_name;
					_tmp108_ = g_markup_escape_text (_tmp107_, (gssize) -1);
					_tmp109_ = _tmp108_;
					_tmp110_ = _data59_->suggestion;
					_tmp111_ = dino_search_suggestion_get_jid (_tmp110_);
					_tmp112_ = _tmp111_;
					_tmp113_ = xmpp_jid_to_string (_tmp112_);
					_tmp114_ = _tmp113_;
					_tmp115_ = g_markup_escape_text (_tmp114_, (gssize) -1);
					_tmp116_ = _tmp115_;
					_tmp117_ = g_strdup_printf ("%s <span font_weight='light' fgalpha='80%%'>%s</span>", _tmp109_, _tmp116_);
					_tmp118_ = _tmp117_;
					gtk_label_set_markup (_tmp106_, _tmp118_);
					_g_free0 (_tmp118_);
					_g_free0 (_tmp116_);
					_g_free0 (_tmp114_);
					_g_free0 (_tmp109_);
				} else {
					GtkLabel* _tmp119_;
					const gchar* _tmp120_;
					_tmp119_ = label;
					_tmp120_ = display_name;
					gtk_label_set_label (_tmp119_, _tmp120_);
				}
				_tmp121_ = (GtkListBoxRow*) gtk_list_box_row_new ();
				gtk_widget_set_visible ((GtkWidget*) _tmp121_, TRUE);
				gtk_widget_set_can_focus ((GtkWidget*) _tmp121_, FALSE);
				g_object_ref_sink (_tmp121_);
				row = _tmp121_;
				_tmp122_ = row;
				_tmp123_ = builder;
				_tmp124_ = gtk_builder_get_object (_tmp123_, "root");
				gtk_list_box_row_set_child (_tmp122_, G_TYPE_CHECK_INSTANCE_CAST (_tmp124_, gtk_widget_get_type (), GtkWidget));
				_tmp125_ = row;
				g_signal_connect_data (_tmp125_, "activate", (GCallback) ______lambda154__gtk_list_box_row_activate, block59_data_ref (_data59_), (GClosureNotify) block59_data_unref, 0);
				_tmp126_ = self->auto_complete_list;
				_tmp127_ = row;
				gtk_list_box_append (_tmp126_, (GtkWidget*) _tmp127_);
				_tmp128_ = self->priv->auto_complete_children;
				_tmp129_ = row;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp128_, (GtkWidget*) _tmp129_);
				_g_object_unref0 (row);
				_g_free0 (display_name);
				_g_object_unref0 (label);
				_g_object_unref0 (avatar);
				_g_object_unref0 (builder);
				block59_data_unref (_data59_);
				_data59_ = NULL;
			}
		}
		_tmp130_ = self->auto_complete_list;
		_tmp131_ = self->auto_complete_list;
		_tmp132_ = gtk_list_box_get_row_at_index (_tmp131_, 0);
		gtk_list_box_select_row (_tmp130_, _tmp132_);
	}
	_g_object_unref0 (suggestions);
}

static void
dino_ui_global_search_handle_suggestion (DinoUiGlobalSearch* self,
                                         DinoSearchSuggestion* suggestion)
{
	GtkSearchEntry* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint position = 0;
	GtkSearchEntry* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	GtkSearchEntry* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	GtkSearchEntry* _tmp17_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (suggestion != NULL);
	_tmp0_ = self->search_entry;
	_tmp1_ = dino_search_suggestion_get_start_index (suggestion);
	_tmp2_ = _tmp1_;
	_tmp3_ = dino_search_suggestion_get_end_index (suggestion);
	_tmp4_ = _tmp3_;
	g_signal_emit_by_name ((GtkEditable*) _tmp0_, "delete-text", _tmp2_, _tmp4_);
	_tmp5_ = self->search_entry;
	g_object_get ((GtkEditable*) _tmp5_, "cursor-position", &_tmp6_, NULL);
	_tmp7_ = _tmp6_;
	position = _tmp7_;
	_tmp8_ = self->search_entry;
	_tmp9_ = dino_search_suggestion_get_completion (suggestion);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_strconcat (_tmp10_, " ", NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = dino_search_suggestion_get_completion (suggestion);
	_tmp14_ = _tmp13_;
	_tmp15_ = strlen (_tmp14_);
	_tmp16_ = _tmp15_;
	g_signal_emit_by_name ((GtkEditable*) _tmp8_, "insert-text", _tmp12_, _tmp16_ + 1, &position);
	_g_free0 (_tmp12_);
	_tmp17_ = self->search_entry;
	gtk_editable_set_position ((GtkEditable*) _tmp17_, -1);
}

static void
dino_ui_global_search_clear_search (DinoUiGlobalSearch* self)
{
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GeeArrayList* _tmp13_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->results_scrolled;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	gtk_adjustment_set_value (_tmp2_, (gdouble) 0);
	{
		GeeArrayList* _widget_list = NULL;
		GeeArrayList* _tmp3_;
		gint _widget_size = 0;
		GeeArrayList* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		gint _widget_index = 0;
		_tmp3_ = self->priv->results_box_children;
		_widget_list = _tmp3_;
		_tmp4_ = _widget_list;
		_tmp5_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		_widget_size = _tmp6_;
		_widget_index = -1;
		while (TRUE) {
			gint _tmp7_;
			gint _tmp8_;
			GtkWidget* widget = NULL;
			GeeArrayList* _tmp9_;
			gpointer _tmp10_;
			GtkBox* _tmp11_;
			GtkWidget* _tmp12_;
			_widget_index = _widget_index + 1;
			_tmp7_ = _widget_index;
			_tmp8_ = _widget_size;
			if (!(_tmp7_ < _tmp8_)) {
				break;
			}
			_tmp9_ = _widget_list;
			_tmp10_ = gee_abstract_list_get ((GeeAbstractList*) _tmp9_, _widget_index);
			widget = (GtkWidget*) _tmp10_;
			_tmp11_ = self->results_box;
			_tmp12_ = widget;
			gtk_box_remove (_tmp11_, _tmp12_);
			_g_object_unref0 (widget);
		}
	}
	_tmp13_ = self->priv->results_box_children;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp13_);
	self->priv->loaded_results = 0;
}

static void
dino_ui_global_search_set_search (DinoUiGlobalSearch* self,
                                  const gchar* search)
{
	gchar* _tmp0_;
	GeeList* _tmp1_;
	GeeList* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	GeeList* messages = NULL;
	DinoStreamInteractor* _tmp7_;
	DinoModuleIdentity* _tmp8_;
	gpointer _tmp9_;
	DinoSearchProcessor* _tmp10_;
	GeeList* _tmp11_;
	GeeList* _tmp12_;
	GeeList* _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (search != NULL);
	dino_ui_global_search_clear_search (self);
	_tmp0_ = g_strdup (search);
	_g_free0 (self->priv->search);
	self->priv->search = _tmp0_;
	_tmp1_ = dino_ui_global_search_get_keywords (search);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_collection_get_is_empty ((GeeCollection*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp2_);
	if (_tmp5_) {
		GtkStack* _tmp6_;
		_tmp6_ = self->results_empty_stack;
		gtk_stack_set_visible_child_name (_tmp6_, "empty");
		return;
	}
	_tmp7_ = self->priv->stream_interactor;
	_tmp8_ = dino_search_processor_IDENTITY;
	_tmp9_ = dino_stream_interactor_get_module (_tmp7_, DINO_TYPE_SEARCH_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp8_);
	_tmp10_ = (DinoSearchProcessor*) _tmp9_;
	_tmp11_ = dino_search_processor_match_messages (_tmp10_, search, -1);
	_tmp12_ = _tmp11_;
	_g_object_unref0 (_tmp10_);
	messages = _tmp12_;
	_tmp13_ = messages;
	_tmp14_ = gee_collection_get_size ((GeeCollection*) _tmp13_);
	_tmp15_ = _tmp14_;
	if (_tmp15_ == 0) {
		GtkStack* _tmp16_;
		_tmp16_ = self->results_empty_stack;
		gtk_stack_set_visible_child_name (_tmp16_, "no-result");
	} else {
		GtkStack* _tmp17_;
		gint _tmp18_ = 0;
		GeeList* _tmp19_;
		gint _tmp20_;
		gint _tmp21_;
		gint match_count = 0;
		GtkLabel* _tmp29_;
		const gchar* _tmp30_;
		gchar* _tmp31_;
		gchar* _tmp32_;
		gchar* _tmp33_;
		gchar* _tmp34_;
		gchar* _tmp35_;
		gchar* _tmp36_;
		GeeList* _tmp37_;
		gint _tmp38_;
		gint _tmp39_;
		GeeList* _tmp40_;
		_tmp17_ = self->results_empty_stack;
		gtk_stack_set_visible_child_name (_tmp17_, "results");
		_tmp19_ = messages;
		_tmp20_ = gee_collection_get_size ((GeeCollection*) _tmp19_);
		_tmp21_ = _tmp20_;
		if (_tmp21_ < 10) {
			GeeList* _tmp22_;
			gint _tmp23_;
			gint _tmp24_;
			_tmp22_ = messages;
			_tmp23_ = gee_collection_get_size ((GeeCollection*) _tmp22_);
			_tmp24_ = _tmp23_;
			_tmp18_ = _tmp24_;
		} else {
			DinoStreamInteractor* _tmp25_;
			DinoModuleIdentity* _tmp26_;
			gpointer _tmp27_;
			DinoSearchProcessor* _tmp28_;
			_tmp25_ = self->priv->stream_interactor;
			_tmp26_ = dino_search_processor_IDENTITY;
			_tmp27_ = dino_stream_interactor_get_module (_tmp25_, DINO_TYPE_SEARCH_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp26_);
			_tmp28_ = (DinoSearchProcessor*) _tmp27_;
			_tmp18_ = dino_search_processor_count_match_messages (_tmp28_, search);
			_g_object_unref0 (_tmp28_);
		}
		match_count = _tmp18_;
		_tmp29_ = self->entry_number_label;
		_tmp30_ = dino_ngettext ("%i search result", "%i search results", (gulong) match_count);
		_tmp31_ = g_strdup_printf (_tmp30_, match_count);
		_tmp32_ = _tmp31_;
		_tmp33_ = g_strconcat ("<i>", _tmp32_, NULL);
		_tmp34_ = _tmp33_;
		_tmp35_ = g_strconcat (_tmp34_, "</i>", NULL);
		_tmp36_ = _tmp35_;
		gtk_label_set_label (_tmp29_, _tmp36_);
		_g_free0 (_tmp36_);
		_g_free0 (_tmp34_);
		_g_free0 (_tmp32_);
		_tmp37_ = messages;
		_tmp38_ = gee_collection_get_size ((GeeCollection*) _tmp37_);
		_tmp39_ = _tmp38_;
		self->priv->loaded_results = self->priv->loaded_results + _tmp39_;
		_tmp40_ = messages;
		dino_ui_global_search_append_messages (self, _tmp40_);
	}
	_g_object_unref0 (messages);
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
dino_ui_global_search_append_messages (DinoUiGlobalSearch* self,
                                       GeeList* messages)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (messages != NULL);
	{
		GeeList* _item_list = NULL;
		gint _item_size = 0;
		GeeList* _tmp0_;
		gint _tmp1_;
		gint _tmp2_;
		gint _item_index = 0;
		_item_list = messages;
		_tmp0_ = _item_list;
		_tmp1_ = gee_collection_get_size ((GeeCollection*) _tmp0_);
		_tmp2_ = _tmp1_;
		_item_size = _tmp2_;
		_item_index = -1;
		while (TRUE) {
			gint _tmp3_;
			gint _tmp4_;
			DinoMessageItem* item = NULL;
			GeeList* _tmp5_;
			gpointer _tmp6_;
			GeeList* before_message = NULL;
			DinoStreamInteractor* _tmp7_;
			DinoModuleIdentity* _tmp8_;
			gpointer _tmp9_;
			DinoMessageStorage* _tmp10_;
			DinoMessageItem* _tmp11_;
			DinoEntitiesConversation* _tmp12_;
			DinoMessageItem* _tmp13_;
			DinoEntitiesMessage* _tmp14_;
			GDateTime* _tmp15_;
			GDateTime* _tmp16_;
			DinoMessageItem* _tmp17_;
			DinoEntitiesMessage* _tmp18_;
			gint _tmp19_;
			gint _tmp20_;
			GeeList* _tmp21_;
			GeeList* _tmp22_;
			GeeList* after_message = NULL;
			DinoStreamInteractor* _tmp23_;
			DinoModuleIdentity* _tmp24_;
			gpointer _tmp25_;
			DinoMessageStorage* _tmp26_;
			DinoMessageItem* _tmp27_;
			DinoEntitiesConversation* _tmp28_;
			DinoMessageItem* _tmp29_;
			DinoEntitiesMessage* _tmp30_;
			GDateTime* _tmp31_;
			GDateTime* _tmp32_;
			DinoMessageItem* _tmp33_;
			DinoEntitiesMessage* _tmp34_;
			gint _tmp35_;
			gint _tmp36_;
			GeeList* _tmp37_;
			GeeList* _tmp38_;
			GtkBox* context_box = NULL;
			GtkBox* _tmp39_;
			gboolean _tmp40_ = FALSE;
			GeeList* _tmp41_;
			GtkWidget* match_widget = NULL;
			DinoMessageItem* _tmp51_;
			GtkWidget* _tmp52_;
			GtkBox* _tmp53_;
			GtkWidget* _tmp54_;
			gboolean _tmp55_ = FALSE;
			GeeList* _tmp56_;
			GtkLabel* date_label = NULL;
			DinoMessageItem* _tmp66_;
			GDateTime* _tmp67_;
			GDateTime* _tmp68_;
			GDateTime* _tmp69_;
			GDateTime* _tmp70_;
			gchar* _tmp71_;
			gchar* _tmp72_;
			GtkLabel* _tmp73_ = NULL;
			GtkLabel* _tmp74_;
			GtkLabel* _tmp75_;
			gchar* display_name = NULL;
			DinoStreamInteractor* _tmp76_;
			DinoMessageItem* _tmp77_;
			DinoEntitiesConversation* _tmp78_;
			gchar* _tmp79_;
			gchar* _tmp80_ = NULL;
			DinoMessageItem* _tmp81_;
			DinoEntitiesMessage* _tmp82_;
			DinoEntitiesMessageType _tmp83_;
			DinoEntitiesMessageType _tmp84_;
			gchar* title = NULL;
			gchar* _tmp91_;
			GtkBox* header_box = NULL;
			GtkBox* _tmp92_ = NULL;
			GtkBox* _tmp93_;
			const gchar* _tmp94_;
			gchar* _tmp95_;
			gchar* _tmp96_;
			const gchar* _tmp97_;
			gchar* _tmp98_;
			gchar* _tmp99_;
			GtkLabel* _tmp100_ = NULL;
			GtkLabel* _tmp101_;
			GtkBox* _tmp102_;
			GtkLabel* _tmp103_;
			GtkBox* result_box = NULL;
			GtkBox* _tmp104_;
			GtkBox* _tmp105_;
			GtkBox* _tmp106_;
			GtkBox* _tmp107_;
			GtkBox* _tmp108_;
			GtkBox* _tmp109_;
			GtkBox* _tmp110_;
			GeeArrayList* _tmp111_;
			GtkBox* _tmp112_;
			_item_index = _item_index + 1;
			_tmp3_ = _item_index;
			_tmp4_ = _item_size;
			if (!(_tmp3_ < _tmp4_)) {
				break;
			}
			_tmp5_ = _item_list;
			_tmp6_ = gee_list_get (_tmp5_, _item_index);
			item = (DinoMessageItem*) _tmp6_;
			_tmp7_ = self->priv->stream_interactor;
			_tmp8_ = dino_message_storage_IDENTITY;
			_tmp9_ = dino_stream_interactor_get_module (_tmp7_, DINO_TYPE_MESSAGE_STORAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp8_);
			_tmp10_ = (DinoMessageStorage*) _tmp9_;
			_tmp11_ = item;
			_tmp12_ = _tmp11_->conversation;
			_tmp13_ = item;
			_tmp14_ = _tmp13_->message;
			_tmp15_ = dino_entities_message_get_time (_tmp14_);
			_tmp16_ = _tmp15_;
			_tmp17_ = item;
			_tmp18_ = _tmp17_->message;
			_tmp19_ = dino_entities_message_get_id (_tmp18_);
			_tmp20_ = _tmp19_;
			_tmp21_ = dino_message_storage_get_messages_before_message (_tmp10_, _tmp12_, _tmp16_, _tmp20_, 1);
			_tmp22_ = _tmp21_;
			_g_object_unref0 (_tmp10_);
			before_message = _tmp22_;
			_tmp23_ = self->priv->stream_interactor;
			_tmp24_ = dino_message_storage_IDENTITY;
			_tmp25_ = dino_stream_interactor_get_module (_tmp23_, DINO_TYPE_MESSAGE_STORAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp24_);
			_tmp26_ = (DinoMessageStorage*) _tmp25_;
			_tmp27_ = item;
			_tmp28_ = _tmp27_->conversation;
			_tmp29_ = item;
			_tmp30_ = _tmp29_->message;
			_tmp31_ = dino_entities_message_get_time (_tmp30_);
			_tmp32_ = _tmp31_;
			_tmp33_ = item;
			_tmp34_ = _tmp33_->message;
			_tmp35_ = dino_entities_message_get_id (_tmp34_);
			_tmp36_ = _tmp35_;
			_tmp37_ = dino_message_storage_get_messages_after_message (_tmp26_, _tmp28_, _tmp32_, _tmp36_, 1);
			_tmp38_ = _tmp37_;
			_g_object_unref0 (_tmp26_);
			after_message = _tmp38_;
			_tmp39_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
			g_object_ref_sink (_tmp39_);
			context_box = _tmp39_;
			_tmp41_ = before_message;
			if (_tmp41_ != NULL) {
				GeeList* _tmp42_;
				gint _tmp43_;
				gint _tmp44_;
				_tmp42_ = before_message;
				_tmp43_ = gee_collection_get_size ((GeeCollection*) _tmp42_);
				_tmp44_ = _tmp43_;
				_tmp40_ = _tmp44_ > 0;
			} else {
				_tmp40_ = FALSE;
			}
			if (_tmp40_) {
				GtkBox* _tmp45_;
				GeeList* _tmp46_;
				gpointer _tmp47_;
				DinoMessageItem* _tmp48_;
				GtkGrid* _tmp49_;
				GtkGrid* _tmp50_;
				_tmp45_ = context_box;
				_tmp46_ = before_message;
				_tmp47_ = gee_list_first (_tmp46_);
				_tmp48_ = (DinoMessageItem*) _tmp47_;
				_tmp49_ = dino_ui_global_search_get_context_message_widget (self, _tmp48_);
				_tmp50_ = _tmp49_;
				gtk_box_append (_tmp45_, (GtkWidget*) _tmp50_);
				_g_object_unref0 (_tmp50_);
				_g_object_unref0 (_tmp48_);
			}
			_tmp51_ = item;
			_tmp52_ = dino_ui_global_search_get_match_message_widget (self, _tmp51_);
			match_widget = _tmp52_;
			_tmp53_ = context_box;
			_tmp54_ = match_widget;
			gtk_box_append (_tmp53_, _tmp54_);
			_tmp56_ = after_message;
			if (_tmp56_ != NULL) {
				GeeList* _tmp57_;
				gint _tmp58_;
				gint _tmp59_;
				_tmp57_ = after_message;
				_tmp58_ = gee_collection_get_size ((GeeCollection*) _tmp57_);
				_tmp59_ = _tmp58_;
				_tmp55_ = _tmp59_ > 0;
			} else {
				_tmp55_ = FALSE;
			}
			if (_tmp55_) {
				GtkBox* _tmp60_;
				GeeList* _tmp61_;
				gpointer _tmp62_;
				DinoMessageItem* _tmp63_;
				GtkGrid* _tmp64_;
				GtkGrid* _tmp65_;
				_tmp60_ = context_box;
				_tmp61_ = after_message;
				_tmp62_ = gee_list_first (_tmp61_);
				_tmp63_ = (DinoMessageItem*) _tmp62_;
				_tmp64_ = dino_ui_global_search_get_context_message_widget (self, _tmp63_);
				_tmp65_ = _tmp64_;
				gtk_box_append (_tmp60_, (GtkWidget*) _tmp65_);
				_g_object_unref0 (_tmp65_);
				_g_object_unref0 (_tmp63_);
			}
			_tmp66_ = item;
			_tmp67_ = dino_content_item_get_time ((DinoContentItem*) _tmp66_);
			_tmp68_ = _tmp67_;
			_tmp69_ = g_date_time_to_local (_tmp68_);
			_tmp70_ = _tmp69_;
			_tmp71_ = dino_ui_conversation_summary_conversation_item_skeleton_get_relative_time (_tmp70_);
			_tmp72_ = _tmp71_;
			_tmp73_ = (GtkLabel*) gtk_label_new (_tmp72_);
			gtk_label_set_xalign (_tmp73_, (gfloat) 0);
			g_object_ref_sink (_tmp73_);
			_tmp74_ = _tmp73_;
			_g_free0 (_tmp72_);
			_g_date_time_unref0 (_tmp70_);
			date_label = _tmp74_;
			_tmp75_ = date_label;
			gtk_widget_add_css_class ((GtkWidget*) _tmp75_, "dim-label");
			_tmp76_ = self->priv->stream_interactor;
			_tmp77_ = item;
			_tmp78_ = _tmp77_->conversation;
			_tmp79_ = dino_ui_util_get_conversation_display_name (_tmp76_, _tmp78_);
			display_name = _tmp79_;
			_tmp81_ = item;
			_tmp82_ = _tmp81_->message;
			_tmp83_ = dino_entities_message_get_type_ (_tmp82_);
			_tmp84_ = _tmp83_;
			if (_tmp84_ == DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT) {
				const gchar* _tmp85_;
				const gchar* _tmp86_;
				gchar* _tmp87_;
				_tmp85_ = dino_gettext ("In %s");
				_tmp86_ = display_name;
				_tmp87_ = g_strdup_printf (_tmp85_, _tmp86_);
				_g_free0 (_tmp80_);
				_tmp80_ = _tmp87_;
			} else {
				const gchar* _tmp88_;
				const gchar* _tmp89_;
				gchar* _tmp90_;
				_tmp88_ = dino_gettext ("With %s");
				_tmp89_ = display_name;
				_tmp90_ = g_strdup_printf (_tmp88_, _tmp89_);
				_g_free0 (_tmp80_);
				_tmp80_ = _tmp90_;
			}
			_tmp91_ = _tmp80_;
			_tmp80_ = NULL;
			title = _tmp91_;
			_tmp92_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
			gtk_widget_set_margin_start ((GtkWidget*) _tmp92_, 7);
			g_object_ref_sink (_tmp92_);
			header_box = _tmp92_;
			_tmp93_ = header_box;
			_tmp94_ = title;
			_tmp95_ = g_markup_escape_text (_tmp94_, (gssize) -1);
			_tmp96_ = _tmp95_;
			_tmp97_ = string_to_string (_tmp96_);
			_tmp98_ = g_strconcat ("<b>", _tmp97_, "</b>", NULL);
			_tmp99_ = _tmp98_;
			_tmp100_ = (GtkLabel*) gtk_label_new (_tmp99_);
			gtk_label_set_ellipsize (_tmp100_, PANGO_ELLIPSIZE_END);
			gtk_label_set_xalign (_tmp100_, (gfloat) 0);
			gtk_label_set_use_markup (_tmp100_, TRUE);
			g_object_ref_sink (_tmp100_);
			_tmp101_ = _tmp100_;
			gtk_box_append (_tmp93_, (GtkWidget*) _tmp101_);
			_g_object_unref0 (_tmp101_);
			_g_free0 (_tmp99_);
			_g_free0 (_tmp96_);
			_tmp102_ = header_box;
			_tmp103_ = date_label;
			gtk_box_append (_tmp102_, (GtkWidget*) _tmp103_);
			_tmp104_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 7);
			g_object_ref_sink (_tmp104_);
			result_box = _tmp104_;
			_tmp105_ = result_box;
			_tmp106_ = header_box;
			gtk_box_append (_tmp105_, (GtkWidget*) _tmp106_);
			_tmp107_ = result_box;
			_tmp108_ = context_box;
			gtk_box_append (_tmp107_, (GtkWidget*) _tmp108_);
			_tmp109_ = self->results_box;
			_tmp110_ = result_box;
			gtk_box_append (_tmp109_, (GtkWidget*) _tmp110_);
			_tmp111_ = self->priv->results_box_children;
			_tmp112_ = result_box;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp111_, (GtkWidget*) _tmp112_);
			_g_object_unref0 (result_box);
			_g_object_unref0 (header_box);
			_g_free0 (title);
			_g_free0 (_tmp80_);
			_g_free0 (display_name);
			_g_object_unref0 (date_label);
			_g_object_unref0 (match_widget);
			_g_object_unref0 (context_box);
			_g_object_unref0 (after_message);
			_g_object_unref0 (before_message);
			_g_object_unref0 (item);
		}
	}
}

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

static void
block60_data_unref (void * _userdata_)
{
	Block60Data* _data60_;
	_data60_ = (Block60Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data60_->_ref_count_)) {
		DinoUiGlobalSearch* self;
		self = _data60_->self;
		_g_object_unref0 (_data60_->item);
		_dino_ui_global_search_unref0 (self);
		g_slice_free (Block60Data, _data60_);
	}
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__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;
}

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 glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gint
string_index_of_nth_char (const gchar* self,
                          glong c)
{
	gchar* _tmp0_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_offset_to_pointer (self, c);
	result = (gint) (_tmp0_ - ((gchar*) self));
	return result;
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static void
__lambda153_ (Block60Data* _data60_)
{
	DinoUiGlobalSearch* self;
	self = _data60_->self;
	g_signal_emit (self, dino_ui_global_search_signals[DINO_UI_GLOBAL_SEARCH_SELECTED_ITEM_SIGNAL], 0, _data60_->item);
}

static void
___lambda153__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda153_ (self);
}

static GtkWidget*
dino_ui_global_search_get_match_message_widget (DinoUiGlobalSearch* self,
                                                DinoMessageItem* item)
{
	Block60Data* _data60_;
	DinoMessageItem* _tmp0_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp1_;
	GtkGrid* _tmp2_;
	GtkGrid* _tmp3_;
	gchar* text = NULL;
	DinoEntitiesMessage* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	const gchar* _tmp12_;
	GtkLabel* label = NULL;
	GtkLabel* _tmp64_ = NULL;
	gchar* regex_str = NULL;
	gchar* _tmp65_;
	GeeList* keywords = NULL;
	const gchar* _tmp66_;
	gchar* _tmp67_;
	gchar* _tmp68_;
	gchar* _tmp69_;
	gchar* _tmp70_;
	GeeList* _tmp71_;
	GeeList* _tmp72_;
	gboolean first = FALSE;
	const gchar* _tmp88_;
	gchar* _tmp89_;
	gchar* markup_text = NULL;
	gchar* _tmp90_;
	GtkLabel* _tmp134_;
	const gchar* _tmp135_;
	GtkGrid* _tmp136_;
	GtkLabel* _tmp137_;
	GtkButton* button = NULL;
	GtkButton* _tmp138_ = NULL;
	GtkGrid* _tmp139_;
	GError* _inner_error0_ = NULL;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (item != NULL, NULL);
	_data60_ = g_slice_new0 (Block60Data);
	_data60_->_ref_count_ = 1;
	_data60_->self = dino_ui_global_search_ref (self);
	_tmp0_ = _g_object_ref0 (item);
	_g_object_unref0 (_data60_->item);
	_data60_->item = _tmp0_;
	_tmp1_ = dino_ui_global_search_get_skeleton (self, _data60_->item);
	grid = _tmp1_;
	_tmp2_ = grid;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp2_, 3);
	_tmp3_ = grid;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp3_, 3);
	_tmp4_ = _data60_->item->message;
	_tmp5_ = dino_entities_message_get_body (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = string_replace (_tmp6_, "\n", "");
	_tmp8_ = _tmp7_;
	_tmp9_ = string_replace (_tmp8_, "\r", "");
	_tmp10_ = dino_ui_util_unbreak_space_around_non_spacing_mark (_tmp9_);
	_tmp11_ = _tmp10_;
	_g_free0 (_tmp8_);
	text = _tmp11_;
	_tmp12_ = text;
	if (g_utf8_strlen (_tmp12_, (gssize) -1) > 200) {
		gint index = 0;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		gint _tmp15_ = 0;
		gint char_index = 0;
		const gchar* _tmp17_;
		_tmp13_ = text;
		_tmp14_ = self->priv->search;
		index = string_index_of (_tmp13_, _tmp14_, 0);
		if (index < 0) {
			_tmp15_ = 0;
		} else {
			const gchar* _tmp16_;
			_tmp16_ = text;
			_tmp15_ = g_utf8_strlen (_tmp16_, (gssize) index);
		}
		char_index = _tmp15_;
		_tmp17_ = self->priv->search;
		if ((char_index + g_utf8_strlen (_tmp17_, (gssize) -1)) <= 100) {
			const gchar* _tmp18_;
			const gchar* _tmp19_;
			gchar* _tmp20_;
			gchar* _tmp21_;
			gchar* _tmp22_;
			gchar* _tmp23_;
			const gchar* _tmp24_;
			const gchar* _tmp25_;
			const gchar* _tmp26_;
			gchar* _tmp27_;
			gchar* _tmp28_;
			gchar* _tmp29_;
			_tmp18_ = text;
			_tmp19_ = text;
			_tmp20_ = string_substring (_tmp18_, (glong) 0, (glong) string_index_of_nth_char (_tmp19_, (glong) 150));
			_tmp21_ = _tmp20_;
			_tmp22_ = g_strconcat (_tmp21_, " … ", NULL);
			_tmp23_ = _tmp22_;
			_tmp24_ = text;
			_tmp25_ = text;
			_tmp26_ = text;
			_tmp27_ = string_substring (_tmp24_, (glong) string_index_of_nth_char (_tmp25_, (glong) (g_utf8_strlen (_tmp26_, (gssize) -1) - 50)), (glong) -1);
			_tmp28_ = _tmp27_;
			_tmp29_ = g_strconcat (_tmp23_, _tmp28_, NULL);
			_g_free0 (text);
			text = _tmp29_;
			_g_free0 (_tmp28_);
			_g_free0 (_tmp23_);
			_g_free0 (_tmp21_);
		} else {
			const gchar* _tmp30_;
			_tmp30_ = text;
			if (char_index >= (g_utf8_strlen (_tmp30_, (gssize) -1) - 100)) {
				const gchar* _tmp31_;
				const gchar* _tmp32_;
				gchar* _tmp33_;
				gchar* _tmp34_;
				gchar* _tmp35_;
				gchar* _tmp36_;
				const gchar* _tmp37_;
				const gchar* _tmp38_;
				const gchar* _tmp39_;
				gchar* _tmp40_;
				gchar* _tmp41_;
				gchar* _tmp42_;
				_tmp31_ = text;
				_tmp32_ = text;
				_tmp33_ = string_substring (_tmp31_, (glong) 0, (glong) string_index_of_nth_char (_tmp32_, (glong) 50));
				_tmp34_ = _tmp33_;
				_tmp35_ = g_strconcat (_tmp34_, " … ", NULL);
				_tmp36_ = _tmp35_;
				_tmp37_ = text;
				_tmp38_ = text;
				_tmp39_ = text;
				_tmp40_ = string_substring (_tmp37_, (glong) string_index_of_nth_char (_tmp38_, (glong) (g_utf8_strlen (_tmp39_, (gssize) -1) - 150)), (glong) -1);
				_tmp41_ = _tmp40_;
				_tmp42_ = g_strconcat (_tmp36_, _tmp41_, NULL);
				_g_free0 (text);
				text = _tmp42_;
				_g_free0 (_tmp41_);
				_g_free0 (_tmp36_);
				_g_free0 (_tmp34_);
			} else {
				const gchar* _tmp43_;
				const gchar* _tmp44_;
				gchar* _tmp45_;
				gchar* _tmp46_;
				gchar* _tmp47_;
				gchar* _tmp48_;
				const gchar* _tmp49_;
				const gchar* _tmp50_;
				const gchar* _tmp51_;
				gchar* _tmp52_;
				gchar* _tmp53_;
				gchar* _tmp54_;
				gchar* _tmp55_;
				gchar* _tmp56_;
				gchar* _tmp57_;
				const gchar* _tmp58_;
				const gchar* _tmp59_;
				const gchar* _tmp60_;
				gchar* _tmp61_;
				gchar* _tmp62_;
				gchar* _tmp63_;
				_tmp43_ = text;
				_tmp44_ = text;
				_tmp45_ = string_substring (_tmp43_, (glong) 0, (glong) string_index_of_nth_char (_tmp44_, (glong) 25));
				_tmp46_ = _tmp45_;
				_tmp47_ = g_strconcat (_tmp46_, " … ", NULL);
				_tmp48_ = _tmp47_;
				_tmp49_ = text;
				_tmp50_ = text;
				_tmp51_ = text;
				_tmp52_ = string_substring (_tmp49_, (glong) string_index_of_nth_char (_tmp50_, (glong) (char_index - 50)), (glong) string_index_of_nth_char (_tmp51_, (glong) (char_index + 100)));
				_tmp53_ = _tmp52_;
				_tmp54_ = g_strconcat (_tmp48_, _tmp53_, NULL);
				_tmp55_ = _tmp54_;
				_tmp56_ = g_strconcat (_tmp55_, " … ", NULL);
				_tmp57_ = _tmp56_;
				_tmp58_ = text;
				_tmp59_ = text;
				_tmp60_ = text;
				_tmp61_ = string_substring (_tmp58_, (glong) string_index_of_nth_char (_tmp59_, (glong) (g_utf8_strlen (_tmp60_, (gssize) -1) - 25)), (glong) -1);
				_tmp62_ = _tmp61_;
				_tmp63_ = g_strconcat (_tmp57_, _tmp62_, NULL);
				_g_free0 (text);
				text = _tmp63_;
				_g_free0 (_tmp62_);
				_g_free0 (_tmp57_);
				_g_free0 (_tmp55_);
				_g_free0 (_tmp53_);
				_g_free0 (_tmp48_);
				_g_free0 (_tmp46_);
			}
		}
	}
	_tmp64_ = (GtkLabel*) gtk_label_new ("");
	gtk_label_set_use_markup (_tmp64_, TRUE);
	gtk_label_set_xalign (_tmp64_, (gfloat) 0);
	gtk_label_set_selectable (_tmp64_, TRUE);
	gtk_label_set_wrap (_tmp64_, TRUE);
	gtk_label_set_wrap_mode (_tmp64_, PANGO_WRAP_WORD_CHAR);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp64_, TRUE);
	g_object_ref_sink (_tmp64_);
	label = _tmp64_;
	_tmp65_ = g_strdup ("(");
	regex_str = _tmp65_;
	_tmp66_ = self->priv->search;
	_tmp67_ = g_utf8_strdown (_tmp66_, (gssize) -1);
	_tmp68_ = _tmp67_;
	_tmp69_ = g_regex_escape_string (_tmp68_, -1);
	_tmp70_ = _tmp69_;
	_tmp71_ = dino_ui_global_search_get_keywords (_tmp70_);
	_tmp72_ = _tmp71_;
	_g_free0 (_tmp70_);
	_g_free0 (_tmp68_);
	keywords = _tmp72_;
	first = TRUE;
	{
		GeeList* _keyword_list = NULL;
		GeeList* _tmp73_;
		gint _keyword_size = 0;
		GeeList* _tmp74_;
		gint _tmp75_;
		gint _tmp76_;
		gint _keyword_index = 0;
		_tmp73_ = keywords;
		_keyword_list = _tmp73_;
		_tmp74_ = _keyword_list;
		_tmp75_ = gee_collection_get_size ((GeeCollection*) _tmp74_);
		_tmp76_ = _tmp75_;
		_keyword_size = _tmp76_;
		_keyword_index = -1;
		while (TRUE) {
			gint _tmp77_;
			gint _tmp78_;
			gchar* keyword = NULL;
			GeeList* _tmp79_;
			gpointer _tmp80_;
			const gchar* _tmp83_;
			const gchar* _tmp84_;
			gchar* _tmp85_;
			gchar* _tmp86_;
			gchar* _tmp87_;
			_keyword_index = _keyword_index + 1;
			_tmp77_ = _keyword_index;
			_tmp78_ = _keyword_size;
			if (!(_tmp77_ < _tmp78_)) {
				break;
			}
			_tmp79_ = _keyword_list;
			_tmp80_ = gee_list_get (_tmp79_, _keyword_index);
			keyword = (gchar*) _tmp80_;
			if (first) {
				first = FALSE;
			} else {
				const gchar* _tmp81_;
				gchar* _tmp82_;
				_tmp81_ = regex_str;
				_tmp82_ = g_strconcat (_tmp81_, "|", NULL);
				_g_free0 (regex_str);
				regex_str = _tmp82_;
			}
			_tmp83_ = regex_str;
			_tmp84_ = keyword;
			_tmp85_ = g_strconcat ("\\b", _tmp84_, NULL);
			_tmp86_ = _tmp85_;
			_tmp87_ = g_strconcat (_tmp83_, _tmp86_, NULL);
			_g_free0 (regex_str);
			regex_str = _tmp87_;
			_g_free0 (_tmp86_);
			_g_free0 (keyword);
		}
	}
	_tmp88_ = regex_str;
	_tmp89_ = g_strconcat (_tmp88_, ")", NULL);
	_g_free0 (regex_str);
	regex_str = _tmp89_;
	_tmp90_ = g_strdup ("");
	markup_text = _tmp90_;
	{
		GRegex* highlight_regex = NULL;
		const gchar* _tmp91_;
		GRegex* _tmp92_;
		GMatchInfo* match_info = NULL;
		GRegex* _tmp93_;
		const gchar* _tmp94_;
		GMatchInfo* _tmp95_ = NULL;
		gint last_end = 0;
		const gchar* _tmp124_;
		const gchar* _tmp125_;
		const gchar* _tmp126_;
		gint _tmp127_;
		gint _tmp128_;
		gchar* _tmp129_;
		gchar* _tmp130_;
		gchar* _tmp131_;
		gchar* _tmp132_;
		gchar* _tmp133_;
		_tmp91_ = regex_str;
		_tmp92_ = g_regex_new (_tmp91_, G_REGEX_CASELESS, 0, &_inner_error0_);
		highlight_regex = _tmp92_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_free0 (markup_text);
			_g_object_unref0 (keywords);
			_g_free0 (regex_str);
			_g_object_unref0 (label);
			_g_free0 (text);
			_g_object_unref0 (grid);
			block60_data_unref (_data60_);
			_data60_ = NULL;
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp93_ = highlight_regex;
		_tmp94_ = text;
		g_regex_match (_tmp93_, _tmp94_, 0, &_tmp95_);
		_g_match_info_unref0 (match_info);
		match_info = _tmp95_;
		last_end = 0;
		{
			gboolean _tmp96_ = FALSE;
			_tmp96_ = TRUE;
			while (TRUE) {
				GMatchInfo* _tmp98_;
				gint start = 0;
				gint end = 0;
				GMatchInfo* _tmp99_;
				gint _tmp100_ = 0;
				gint _tmp101_ = 0;
				const gchar* _tmp102_ = NULL;
				GtkLabel* _tmp103_;
				gchar* themed_span = NULL;
				gchar* _tmp104_;
				const gchar* _tmp105_;
				const gchar* _tmp106_;
				gchar* _tmp107_;
				gchar* _tmp108_;
				gchar* _tmp109_;
				gchar* _tmp110_;
				const gchar* _tmp111_;
				gchar* _tmp112_;
				gchar* _tmp113_;
				const gchar* _tmp114_;
				gchar* _tmp115_;
				gchar* _tmp116_;
				gchar* _tmp117_;
				gchar* _tmp118_;
				gchar* _tmp119_;
				gchar* _tmp120_;
				gchar* _tmp121_;
				gchar* _tmp122_;
				gchar* _tmp123_;
				if (!_tmp96_) {
					GMatchInfo* _tmp97_;
					_tmp97_ = match_info;
					g_match_info_next (_tmp97_, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_g_match_info_unref0 (match_info);
						_g_regex_unref0 (highlight_regex);
						if (_inner_error0_->domain == G_REGEX_ERROR) {
							goto __catch0_g_regex_error;
						}
						_g_free0 (markup_text);
						_g_object_unref0 (keywords);
						_g_free0 (regex_str);
						_g_object_unref0 (label);
						_g_free0 (text);
						_g_object_unref0 (grid);
						block60_data_unref (_data60_);
						_data60_ = NULL;
						g_critical ("file %s: line %d: unexpected 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;
					}
				}
				_tmp96_ = FALSE;
				_tmp98_ = match_info;
				if (!g_match_info_matches (_tmp98_)) {
					break;
				}
				_tmp99_ = match_info;
				g_match_info_fetch_pos (_tmp99_, 0, &_tmp100_, &_tmp101_);
				start = _tmp100_;
				end = _tmp101_;
				_tmp103_ = label;
				if (dino_ui_util_is_dark_theme ((GtkWidget*) _tmp103_)) {
					_tmp102_ = "<span color=\"black\" bgcolor=\"yellow\">";
				} else {
					_tmp102_ = "<span bgcolor=\"yellow\">";
				}
				_tmp104_ = g_strdup (_tmp102_);
				themed_span = _tmp104_;
				_tmp105_ = markup_text;
				_tmp106_ = text;
				_tmp107_ = string_slice (_tmp106_, (glong) last_end, (glong) start);
				_tmp108_ = _tmp107_;
				_tmp109_ = g_markup_escape_text (_tmp108_, (gssize) -1);
				_tmp110_ = _tmp109_;
				_tmp111_ = themed_span;
				_tmp112_ = g_strconcat (_tmp110_, _tmp111_, NULL);
				_tmp113_ = _tmp112_;
				_tmp114_ = text;
				_tmp115_ = string_slice (_tmp114_, (glong) start, (glong) end);
				_tmp116_ = _tmp115_;
				_tmp117_ = g_markup_escape_text (_tmp116_, (gssize) -1);
				_tmp118_ = _tmp117_;
				_tmp119_ = g_strconcat (_tmp113_, _tmp118_, NULL);
				_tmp120_ = _tmp119_;
				_tmp121_ = g_strconcat (_tmp120_, "</span>", NULL);
				_tmp122_ = _tmp121_;
				_tmp123_ = g_strconcat (_tmp105_, _tmp122_, NULL);
				_g_free0 (markup_text);
				markup_text = _tmp123_;
				_g_free0 (_tmp122_);
				_g_free0 (_tmp120_);
				_g_free0 (_tmp118_);
				_g_free0 (_tmp116_);
				_g_free0 (_tmp113_);
				_g_free0 (_tmp110_);
				_g_free0 (_tmp108_);
				last_end = end;
				_g_free0 (themed_span);
			}
		}
		_tmp124_ = markup_text;
		_tmp125_ = text;
		_tmp126_ = text;
		_tmp127_ = strlen (_tmp126_);
		_tmp128_ = _tmp127_;
		_tmp129_ = string_slice (_tmp125_, (glong) last_end, (glong) _tmp128_);
		_tmp130_ = _tmp129_;
		_tmp131_ = g_markup_escape_text (_tmp130_, (gssize) -1);
		_tmp132_ = _tmp131_;
		_tmp133_ = g_strconcat (_tmp124_, _tmp132_, NULL);
		_g_free0 (markup_text);
		markup_text = _tmp133_;
		_g_free0 (_tmp132_);
		_g_free0 (_tmp130_);
		_g_match_info_unref0 (match_info);
		_g_regex_unref0 (highlight_regex);
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (markup_text);
		_g_object_unref0 (keywords);
		_g_free0 (regex_str);
		_g_object_unref0 (label);
		_g_free0 (text);
		_g_object_unref0 (grid);
		block60_data_unref (_data60_);
		_data60_ = 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 NULL;
	}
	_tmp134_ = label;
	_tmp135_ = markup_text;
	gtk_label_set_label (_tmp134_, _tmp135_);
	_tmp136_ = grid;
	_tmp137_ = label;
	gtk_grid_attach (_tmp136_, (GtkWidget*) _tmp137_, 1, 1, 1, 1);
	_tmp138_ = (GtkButton*) gtk_button_new ();
	gtk_button_set_has_frame (_tmp138_, FALSE);
	g_object_ref_sink (_tmp138_);
	button = _tmp138_;
	g_signal_connect_data (button, "clicked", (GCallback) ___lambda153__gtk_button_clicked, block60_data_ref (_data60_), (GClosureNotify) block60_data_unref, 0);
	_tmp139_ = grid;
	gtk_button_set_child (button, (GtkWidget*) _tmp139_);
	result = (GtkWidget*) button;
	_g_free0 (markup_text);
	_g_object_unref0 (keywords);
	_g_free0 (regex_str);
	_g_object_unref0 (label);
	_g_free0 (text);
	_g_object_unref0 (grid);
	block60_data_unref (_data60_);
	_data60_ = NULL;
	return result;
}

static GtkGrid*
dino_ui_global_search_get_context_message_widget (DinoUiGlobalSearch* self,
                                                  DinoMessageItem* item)
{
	GtkGrid* grid = NULL;
	GtkGrid* _tmp0_;
	GtkLabel* label = NULL;
	DinoEntitiesMessage* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GtkLabel* _tmp8_ = NULL;
	GtkLabel* _tmp9_;
	GtkGrid* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (item != NULL, NULL);
	_tmp0_ = dino_ui_global_search_get_skeleton (self, item);
	grid = _tmp0_;
	gtk_widget_set_margin_start ((GtkWidget*) grid, 7);
	_tmp1_ = item->message;
	_tmp2_ = dino_entities_message_get_body (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = string_replace (_tmp3_, "\n", "");
	_tmp5_ = _tmp4_;
	_tmp6_ = string_replace (_tmp5_, "\r", "");
	_tmp7_ = _tmp6_;
	_tmp8_ = (GtkLabel*) gtk_label_new (_tmp7_);
	gtk_label_set_ellipsize (_tmp8_, PANGO_ELLIPSIZE_MIDDLE);
	gtk_label_set_xalign (_tmp8_, (gfloat) 0);
	g_object_ref_sink (_tmp8_);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	label = _tmp9_;
	gtk_grid_attach (grid, (GtkWidget*) label, 1, 1, 1, 1);
	gtk_widget_set_opacity ((GtkWidget*) grid, 0.55);
	result = grid;
	_g_object_unref0 (label);
	return result;
}

static GtkGrid*
dino_ui_global_search_get_skeleton (DinoUiGlobalSearch* self,
                                    DinoMessageItem* item)
{
	DinoUiAvatarPicture* picture = NULL;
	DinoUiAvatarPicture* _tmp0_ = NULL;
	DinoStreamInteractor* _tmp1_;
	DinoUiViewModelCompatAvatarPictureModel* _tmp2_;
	DinoUiViewModelCompatAvatarPictureModel* _tmp3_;
	DinoEntitiesConversation* _tmp4_;
	XmppJid* _tmp5_;
	XmppJid* _tmp6_;
	DinoUiViewModelCompatAvatarPictureModel* _tmp7_;
	DinoUiViewModelCompatAvatarPictureModel* _tmp8_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp9_ = NULL;
	gchar* display_name = NULL;
	DinoStreamInteractor* _tmp10_;
	DinoEntitiesConversation* _tmp11_;
	XmppJid* _tmp12_;
	XmppJid* _tmp13_;
	gchar* _tmp14_;
	GtkLabel* name_label = NULL;
	GtkLabel* _tmp15_ = NULL;
	PangoAttrList* _tmp16_;
	PangoAttrList* _tmp17_;
	PangoAttrList* _tmp18_;
	PangoAttrList* _tmp19_;
	PangoAttribute* _tmp20_;
	GtkGrid* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (item != NULL, NULL);
	_tmp0_ = dino_ui_avatar_picture_new ();
	g_object_set ((GtkWidget*) _tmp0_, "height-request", 32, NULL);
	g_object_set ((GtkWidget*) _tmp0_, "width-request", 32, NULL);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp0_, 7);
	gtk_widget_set_valign ((GtkWidget*) _tmp0_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp0_);
	picture = _tmp0_;
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = dino_ui_view_model_compat_avatar_picture_model_new (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = item->conversation;
	_tmp5_ = dino_content_item_get_jid ((DinoContentItem*) item);
	_tmp6_ = _tmp5_;
	_tmp7_ = dino_ui_view_model_compat_avatar_picture_model_add_participant (_tmp3_, _tmp4_, _tmp6_);
	_tmp8_ = _tmp7_;
	dino_ui_avatar_picture_set_model (picture, (DinoUiViewModelAvatarPictureModel*) _tmp8_);
	_g_object_unref0 (_tmp8_);
	_g_object_unref0 (_tmp3_);
	_tmp9_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_row_homogeneous (_tmp9_, FALSE);
	g_object_ref_sink (_tmp9_);
	grid = _tmp9_;
	gtk_grid_attach (grid, (GtkWidget*) picture, 0, 0, 1, 2);
	_tmp10_ = self->priv->stream_interactor;
	_tmp11_ = item->conversation;
	_tmp12_ = dino_content_item_get_jid ((DinoContentItem*) item);
	_tmp13_ = _tmp12_;
	_tmp14_ = dino_ui_util_get_participant_display_name (_tmp10_, _tmp11_, _tmp13_, FALSE);
	display_name = _tmp14_;
	_tmp15_ = (GtkLabel*) gtk_label_new (display_name);
	gtk_label_set_ellipsize (_tmp15_, PANGO_ELLIPSIZE_END);
	gtk_label_set_xalign (_tmp15_, (gfloat) 0);
	g_object_ref_sink (_tmp15_);
	name_label = _tmp15_;
	_tmp16_ = pango_attr_list_new ();
	_tmp17_ = _tmp16_;
	gtk_label_set_attributes (name_label, _tmp17_);
	_pango_attr_list_unref0 (_tmp17_);
	_tmp18_ = gtk_label_get_attributes (name_label);
	_tmp19_ = _tmp18_;
	_tmp20_ = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
	pango_attr_list_insert (_tmp19_, _tmp20_);
	gtk_grid_attach (grid, (GtkWidget*) name_label, 1, 0, 1, 1);
	result = grid;
	_g_object_unref0 (name_label);
	_g_free0 (display_name);
	_g_object_unref0 (picture);
	return result;
}

static GeeList*
dino_ui_global_search_get_keywords (const gchar* search_string)
{
	GeeList* ret = NULL;
	GeeArrayList* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	GeeList* result;
	g_return_val_if_fail (search_string != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	ret = (GeeList*) _tmp0_;
	_tmp2_ = _tmp1_ = g_strsplit (search_string, " ", 0);
	{
		gchar** search_collection = NULL;
		gint search_collection_length1 = 0;
		gint _search_collection_size_ = 0;
		gint search_it = 0;
		search_collection = _tmp2_;
		search_collection_length1 = _vala_array_length (_tmp1_);
		for (search_it = 0; search_it < search_collection_length1; search_it = search_it + 1) {
			gchar* _tmp3_;
			gchar* search = NULL;
			_tmp3_ = g_strdup (search_collection[search_it]);
			search = _tmp3_;
			{
				gboolean _tmp4_ = FALSE;
				gboolean _tmp5_ = FALSE;
				const gchar* _tmp6_;
				gboolean is_filter = FALSE;
				gboolean _tmp9_ = FALSE;
				_tmp6_ = search;
				if (g_str_has_prefix (_tmp6_, "from:")) {
					_tmp5_ = TRUE;
				} else {
					const gchar* _tmp7_;
					_tmp7_ = search;
					_tmp5_ = g_str_has_prefix (_tmp7_, "in:");
				}
				if (_tmp5_) {
					_tmp4_ = TRUE;
				} else {
					const gchar* _tmp8_;
					_tmp8_ = search;
					_tmp4_ = g_str_has_prefix (_tmp8_, "with:");
				}
				is_filter = _tmp4_;
				if (!is_filter) {
					const gchar* _tmp10_;
					_tmp10_ = search;
					_tmp9_ = g_strcmp0 (_tmp10_, "") != 0;
				} else {
					_tmp9_ = FALSE;
				}
				if (_tmp9_) {
					GeeList* _tmp11_;
					const gchar* _tmp12_;
					_tmp11_ = ret;
					_tmp12_ = search;
					gee_collection_add ((GeeCollection*) _tmp11_, _tmp12_);
				}
				_g_free0 (search);
			}
		}
		search_collection = (_vala_array_free (search_collection, search_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	result = ret;
	return result;
}

GtkWidget*
dino_ui_global_search_get_widget (DinoUiGlobalSearch* self)
{
	GtkOverlay* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->overlay;
	_tmp1_ = _g_object_ref0 ((GtkWidget*) _tmp0_);
	result = _tmp1_;
	return result;
}

static void
dino_ui_value_global_search_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dino_ui_value_global_search_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dino_ui_global_search_unref (value->data[0].v_pointer);
	}
}

static void
dino_ui_value_global_search_copy_value (const GValue* src_value,
                                        GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dino_ui_global_search_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dino_ui_value_global_search_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dino_ui_value_global_search_collect_value (GValue* value,
                                           guint n_collect_values,
                                           GTypeCValue* collect_values,
                                           guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DinoUiGlobalSearch * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dino_ui_global_search_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dino_ui_value_global_search_lcopy_value (const GValue* value,
                                         guint n_collect_values,
                                         GTypeCValue* collect_values,
                                         guint collect_flags)
{
	DinoUiGlobalSearch ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dino_ui_global_search_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
dino_ui_param_spec_global_search (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags)
{
	DinoUiParamSpecGlobalSearch* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DINO_UI_TYPE_GLOBAL_SEARCH), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
dino_ui_value_get_global_search (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_UI_TYPE_GLOBAL_SEARCH), NULL);
	return value->data[0].v_pointer;
}

void
dino_ui_value_set_global_search (GValue* value,
                                 gpointer v_object)
{
	DinoUiGlobalSearch * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_UI_TYPE_GLOBAL_SEARCH));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_UI_TYPE_GLOBAL_SEARCH));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dino_ui_global_search_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_ui_global_search_unref (old);
	}
}

void
dino_ui_value_take_global_search (GValue* value,
                                  gpointer v_object)
{
	DinoUiGlobalSearch * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_UI_TYPE_GLOBAL_SEARCH));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_UI_TYPE_GLOBAL_SEARCH));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_ui_global_search_unref (old);
	}
}

static void
dino_ui_global_search_class_init (DinoUiGlobalSearchClass * klass,
                                  gpointer klass_data)
{
	dino_ui_global_search_parent_class = g_type_class_peek_parent (klass);
	((DinoUiGlobalSearchClass *) klass)->finalize = dino_ui_global_search_finalize;
	g_type_class_adjust_private_offset (klass, &DinoUiGlobalSearch_private_offset);
	dino_ui_global_search_signals[DINO_UI_GLOBAL_SEARCH_SELECTED_ITEM_SIGNAL] = g_signal_new ("selected-item", DINO_UI_TYPE_GLOBAL_SEARCH, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DINO_TYPE_MESSAGE_ITEM);
}

static void
dino_ui_global_search_instance_init (DinoUiGlobalSearch * self,
                                     gpointer klass)
{
	gchar* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	self->priv = dino_ui_global_search_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->search = _tmp0_;
	self->priv->loaded_results = -1;
	g_mutex_init (&self->priv->reloading_mutex);
	_tmp1_ = gee_array_list_new (gtk_widget_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->auto_complete_children = _tmp1_;
	_tmp2_ = gee_array_list_new (gtk_widget_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->results_box_children = _tmp2_;
	self->ref_count = 1;
}

static void
dino_ui_global_search_finalize (DinoUiGlobalSearch * obj)
{
	DinoUiGlobalSearch * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_TYPE_GLOBAL_SEARCH, DinoUiGlobalSearch);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->stream_interactor);
	_g_free0 (self->priv->search);
	_vala_clear_GMutex (&self->priv->reloading_mutex);
	_g_object_unref0 (self->overlay);
	_g_object_unref0 (self->search_entry);
	_g_object_unref0 (self->entry_number_label);
	_g_object_unref0 (self->results_scrolled);
	_g_object_unref0 (self->results_box);
	_g_object_unref0 (self->results_empty_stack);
	_g_object_unref0 (self->auto_complete_overlay);
	_g_object_unref0 (self->auto_complete_list);
	_g_object_unref0 (self->priv->auto_complete_children);
	_g_object_unref0 (self->priv->results_box_children);
}

static GType
dino_ui_global_search_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dino_ui_value_global_search_init, dino_ui_value_global_search_free_value, dino_ui_value_global_search_copy_value, dino_ui_value_global_search_peek_pointer, "p", dino_ui_value_global_search_collect_value, "p", dino_ui_value_global_search_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiGlobalSearchClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_global_search_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiGlobalSearch), 0, (GInstanceInitFunc) dino_ui_global_search_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dino_ui_global_search_type_id;
	dino_ui_global_search_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DinoUiGlobalSearch", &g_define_type_info, &g_define_type_fundamental_info, 0);
	DinoUiGlobalSearch_private_offset = g_type_add_instance_private (dino_ui_global_search_type_id, sizeof (DinoUiGlobalSearchPrivate));
	return dino_ui_global_search_type_id;
}

GType
dino_ui_global_search_get_type (void)
{
	static volatile gsize dino_ui_global_search_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_global_search_type_id__once)) {
		GType dino_ui_global_search_type_id;
		dino_ui_global_search_type_id = dino_ui_global_search_get_type_once ();
		g_once_init_leave (&dino_ui_global_search_type_id__once, dino_ui_global_search_type_id);
	}
	return dino_ui_global_search_type_id__once;
}

gpointer
dino_ui_global_search_ref (gpointer instance)
{
	DinoUiGlobalSearch * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
dino_ui_global_search_unref (gpointer instance)
{
	DinoUiGlobalSearch * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DINO_UI_GLOBAL_SEARCH_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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 void
_vala_clear_GMutex (GMutex * mutex)
{
	GMutex zero_mutex = { 0 };
	if (memcmp (mutex, &zero_mutex, sizeof (GMutex))) {
		g_mutex_clear (mutex);
		memset (mutex, 0, sizeof (GMutex));
	}
}

static void
_vala_clear_GRecMutex (GRecMutex * mutex)
{
	GRecMutex zero_mutex = { 0 };
	if (memcmp (mutex, &zero_mutex, sizeof (GRecMutex))) {
		g_rec_mutex_clear (mutex);
		memset (mutex, 0, sizeof (GRecMutex));
	}
}

static void
_vala_clear_GRWLock (GRWLock * mutex)
{
	GRWLock zero_mutex = { 0 };
	if (memcmp (mutex, &zero_mutex, sizeof (GRWLock))) {
		g_rw_lock_clear (mutex);
		memset (mutex, 0, sizeof (GRWLock));
	}
}

static void
_vala_clear_GCond (GCond * mutex)
{
	GCond zero_mutex = { 0 };
	if (memcmp (mutex, &zero_mutex, sizeof (GCond))) {
		g_cond_clear (mutex);
		memset (mutex, 0, sizeof (GCond));
	}
}

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

