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

#include <gtk/gtk.h>
#include <glib-object.h>
#include "libdino.h"
#include <gee.h>
#include <glib.h>
#include <gio/gio.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.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_CONVERSATION_SELECTOR (dino_ui_conversation_selector_get_type ())
#define DINO_UI_CONVERSATION_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_CONVERSATION_SELECTOR, DinoUiConversationSelector))
#define DINO_UI_CONVERSATION_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_CONVERSATION_SELECTOR, DinoUiConversationSelectorClass))
#define DINO_UI_IS_CONVERSATION_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_CONVERSATION_SELECTOR))
#define DINO_UI_IS_CONVERSATION_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_CONVERSATION_SELECTOR))
#define DINO_UI_CONVERSATION_SELECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_CONVERSATION_SELECTOR, DinoUiConversationSelectorClass))

typedef struct _DinoUiConversationSelector DinoUiConversationSelector;
typedef struct _DinoUiConversationSelectorClass DinoUiConversationSelectorClass;
typedef struct _DinoUiConversationSelectorPrivate DinoUiConversationSelectorPrivate;

#define DINO_UI_TYPE_CONVERSATION_SELECTOR_ROW (dino_ui_conversation_selector_row_get_type ())
#define DINO_UI_CONVERSATION_SELECTOR_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_CONVERSATION_SELECTOR_ROW, DinoUiConversationSelectorRow))
#define DINO_UI_CONVERSATION_SELECTOR_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_CONVERSATION_SELECTOR_ROW, DinoUiConversationSelectorRowClass))
#define DINO_UI_IS_CONVERSATION_SELECTOR_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_CONVERSATION_SELECTOR_ROW))
#define DINO_UI_IS_CONVERSATION_SELECTOR_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_CONVERSATION_SELECTOR_ROW))
#define DINO_UI_CONVERSATION_SELECTOR_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_CONVERSATION_SELECTOR_ROW, DinoUiConversationSelectorRowClass))

typedef struct _DinoUiConversationSelectorRow DinoUiConversationSelectorRow;
typedef struct _DinoUiConversationSelectorRowClass DinoUiConversationSelectorRowClass;
enum  {
	DINO_UI_CONVERSATION_SELECTOR_0_PROPERTY,
	DINO_UI_CONVERSATION_SELECTOR_NUM_PROPERTIES
};
static GParamSpec* dino_ui_conversation_selector_properties[DINO_UI_CONVERSATION_SELECTOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block49Data Block49Data;
typedef struct _Block50Data Block50Data;
typedef struct _DinoUiConversationSelectorRowPrivate DinoUiConversationSelectorRowPrivate;

#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;
typedef struct _DinoUiConversationSelectorRemoveConversationData DinoUiConversationSelectorRemoveConversationData;
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	DINO_UI_CONVERSATION_SELECTOR_CONVERSATION_SELECTED_SIGNAL,
	DINO_UI_CONVERSATION_SELECTOR_NUM_SIGNALS
};
static guint dino_ui_conversation_selector_signals[DINO_UI_CONVERSATION_SELECTOR_NUM_SIGNALS] = {0};

struct _DinoUiConversationSelector {
	GtkWidget parent_instance;
	DinoUiConversationSelectorPrivate * priv;
};

struct _DinoUiConversationSelectorClass {
	GtkWidgetClass parent_class;
};

struct _DinoUiConversationSelectorPrivate {
	GtkListBox* list_box;
	DinoStreamInteractor* stream_interactor;
	GeeHashMap* rows;
};

struct _Block49Data {
	int _ref_count_;
	DinoUiConversationSelector* self;
	DinoEntitiesConversation* conversation;
};

struct _Block50Data {
	int _ref_count_;
	Block49Data * _data49_;
	guint drag_timeout;
};

struct _DinoUiConversationSelectorRow {
	GtkListBoxRow parent_instance;
	DinoUiConversationSelectorRowPrivate * priv;
	DinoUiAvatarPicture* picture;
	GtkLabel* name_label;
	GtkLabel* time_label;
	GtkLabel* nick_label;
	GtkLabel* message_label;
	GtkLabel* unread_count_label;
	GtkImage* pinned_image;
	GtkRevealer* main_revealer;
	DinoContentItem* last_content_item;
	gint num_unread;
	DinoStreamInteractor* stream_interactor;
};

struct _DinoUiConversationSelectorRowClass {
	GtkListBoxRowClass parent_class;
};

struct _DinoUiConversationSelectorRemoveConversationData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoUiConversationSelector* self;
	DinoEntitiesConversation* conversation;
	GeeHashMap* _tmp0_;
	GtkListBox* _tmp1_;
	guint _tmp2_;
	GQuark _tmp3_;
	DinoUiConversationSelectorRow* conversation_row;
	GeeHashMap* _tmp4_;
	gpointer _tmp5_;
	DinoUiConversationSelectorRow* _tmp6_;
	GtkListBox* _tmp7_;
	DinoUiConversationSelectorRow* _tmp8_;
};

static gint DinoUiConversationSelector_private_offset;
static gpointer dino_ui_conversation_selector_parent_class = NULL;

VALA_EXTERN GType dino_ui_conversation_selector_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiConversationSelector, g_object_unref)
VALA_EXTERN GType dino_ui_conversation_selector_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiConversationSelectorRow, g_object_unref)
static guint _dino_entities_conversation_hash_func_gee_hash_data_func (gconstpointer v,
                                                                gpointer self);
static gboolean _dino_entities_conversation_equals_func_gee_equal_data_func (gconstpointer a,
                                                                      gconstpointer b,
                                                                      gpointer self);
VALA_EXTERN DinoUiConversationSelector* dino_ui_conversation_selector_init (DinoUiConversationSelector* self,
                                                                DinoStreamInteractor* stream_interactor);
static void dino_ui_conversation_selector_add_conversation (DinoUiConversationSelector* self,
                                                     DinoEntitiesConversation* conversation);
static void _dino_ui_conversation_selector_add_conversation_dino_conversation_manager_conversation_activated (DinoConversationManager* _sender,
                                                                                                       DinoEntitiesConversation* conversation,
                                                                                                       gpointer self);
static void dino_ui_conversation_selector_remove_conversation (DinoUiConversationSelector* self,
                                                        DinoEntitiesConversation* conversation,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
static void dino_ui_conversation_selector_remove_conversation_finish (DinoUiConversationSelector* self,
                                                               GAsyncResult* _res_);
static void _dino_ui_conversation_selector_remove_conversation_dino_conversation_manager_conversation_deactivated (DinoConversationManager* _sender,
                                                                                                            DinoEntitiesConversation* conversation,
                                                                                                            gpointer self);
static void dino_ui_conversation_selector_on_content_item_received (DinoUiConversationSelector* self,
                                                             DinoContentItem* item,
                                                             DinoEntitiesConversation* conversation);
static void _dino_ui_conversation_selector_on_content_item_received_dino_content_item_store_new_item (DinoContentItemStore* _sender,
                                                                                               DinoContentItem* item,
                                                                                               DinoEntitiesConversation* conversation,
                                                                                               gpointer self);
static gboolean __lambda149_ (DinoUiConversationSelector* self);
VALA_EXTERN void dino_ui_conversation_selector_row_update (DinoUiConversationSelectorRow* self);
static gboolean ___lambda149__gsource_func (gpointer self);
VALA_EXTERN void dino_ui_conversation_selector_row_activated (DinoUiConversationSelector* self,
                                                  GtkListBoxRow* r);
VALA_EXTERN DinoEntitiesConversation* dino_ui_conversation_selector_row_get_conversation (DinoUiConversationSelectorRow* self);
VALA_EXTERN void dino_ui_conversation_selector_on_conversation_selected (DinoUiConversationSelector* self,
                                                             DinoEntitiesConversation* conversation);
static Block49Data* block49_data_ref (Block49Data* _data49_);
static void block49_data_unref (void * _userdata_);
static Block50Data* block50_data_ref (Block50Data* _data50_);
static void block50_data_unref (void * _userdata_);
static void _gtk_list_box_invalidate_sort_g_object_notify (GObject* _sender,
                                                    GParamSpec* pspec,
                                                    gpointer self);
VALA_EXTERN DinoUiConversationSelectorRow* dino_ui_conversation_selector_row_new (DinoStreamInteractor* stream_interactor,
                                                                      DinoEntitiesConversation* conversation);
VALA_EXTERN DinoUiConversationSelectorRow* dino_ui_conversation_selector_row_construct (GType object_type,
                                                                            DinoStreamInteractor* stream_interactor,
                                                                            DinoEntitiesConversation* conversation);
VALA_EXTERN GType dino_ui_avatar_picture_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiAvatarPicture, g_object_unref)
static void ___lambda146_ (Block50Data* _data50_,
                    gdouble x,
                    gdouble y);
static gboolean __lambda147_ (Block50Data* _data50_);
static gboolean ___lambda147__gsource_func (gpointer self);
static void ____lambda146__gtk_drop_controller_motion_motion (GtkDropControllerMotion* _sender,
                                                       gdouble x,
                                                       gdouble y,
                                                       gpointer self);
static void ___lambda148_ (Block50Data* _data50_);
static void ____lambda148__gtk_drop_controller_motion_leave (GtkDropControllerMotion* _sender,
                                                      gpointer self);
static void dino_ui_conversation_selector_select_fallback_conversation (DinoUiConversationSelector* self,
                                                                 DinoEntitiesConversation* conversation);
static void dino_ui_conversation_selector_remove_conversation_data_free (gpointer _data);
static gboolean dino_ui_conversation_selector_remove_conversation_co (DinoUiConversationSelectorRemoveConversationData* _data_);
VALA_EXTERN void dino_ui_conversation_selector_row_colapse (DinoUiConversationSelectorRow* self,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN void dino_ui_conversation_selector_row_colapse_finish (DinoUiConversationSelectorRow* self,
                                                       GAsyncResult* _res_);
static void dino_ui_conversation_selector_remove_conversation_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_);
VALA_EXTERN void dino_ui_conversation_selector_loop_conversations (DinoUiConversationSelector* self,
                                                       gboolean backwards);
static gint dino_ui_conversation_selector_sort (DinoUiConversationSelector* self,
                                         GtkListBoxRow* row1,
                                         GtkListBoxRow* row2);
VALA_EXTERN gchar* dino_ui_util_get_conversation_display_name (DinoStreamInteractor* stream_interactor,
                                                   DinoEntitiesConversation* conversation);
VALA_EXTERN DinoUiConversationSelector* dino_ui_conversation_selector_new (void);
VALA_EXTERN DinoUiConversationSelector* dino_ui_conversation_selector_construct (GType object_type);
static GObject * dino_ui_conversation_selector_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties);
static gint _dino_ui_conversation_selector_sort_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                                 GtkListBoxRow* row2,
                                                                 gpointer self);
static void _dino_ui_conversation_selector___lambda150_ (DinoUiConversationSelector* self);
static void __dino_ui_conversation_selector___lambda150__gtk_widget_realize (GtkWidget* _sender,
                                                                      gpointer self);
static void _dino_ui_conversation_selector_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                              GtkListBoxRow* row,
                                                                              gpointer self);
static void dino_ui_conversation_selector_finalize (GObject * obj);
static GType dino_ui_conversation_selector_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_ui_conversation_selector_get_instance_private (DinoUiConversationSelector* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiConversationSelector_private_offset);
}

static guint
_dino_entities_conversation_hash_func_gee_hash_data_func (gconstpointer v,
                                                          gpointer self)
{
	guint result;
	result = dino_entities_conversation_hash_func ((DinoEntitiesConversation*) v);
	return result;
}

static gboolean
_dino_entities_conversation_equals_func_gee_equal_data_func (gconstpointer a,
                                                             gconstpointer b,
                                                             gpointer self)
{
	gboolean result;
	result = dino_entities_conversation_equals_func ((DinoEntitiesConversation*) a, (DinoEntitiesConversation*) b);
	return result;
}

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

static void
_dino_ui_conversation_selector_add_conversation_dino_conversation_manager_conversation_activated (DinoConversationManager* _sender,
                                                                                                  DinoEntitiesConversation* conversation,
                                                                                                  gpointer self)
{
	dino_ui_conversation_selector_add_conversation ((DinoUiConversationSelector*) self, conversation);
}

static void
_dino_ui_conversation_selector_remove_conversation_dino_conversation_manager_conversation_deactivated (DinoConversationManager* _sender,
                                                                                                       DinoEntitiesConversation* conversation,
                                                                                                       gpointer self)
{
	dino_ui_conversation_selector_remove_conversation ((DinoUiConversationSelector*) self, conversation, NULL, NULL);
}

static void
_dino_ui_conversation_selector_on_content_item_received_dino_content_item_store_new_item (DinoContentItemStore* _sender,
                                                                                          DinoContentItem* item,
                                                                                          DinoEntitiesConversation* conversation,
                                                                                          gpointer self)
{
	dino_ui_conversation_selector_on_content_item_received ((DinoUiConversationSelector*) self, item, conversation);
}

static gboolean
__lambda149_ (DinoUiConversationSelector* self)
{
	gboolean result;
	{
		GeeIterator* _row_it = NULL;
		GeeHashMap* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->rows;
		_tmp1_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_row_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			DinoUiConversationSelectorRow* row = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			DinoUiConversationSelectorRow* _tmp9_;
			_tmp6_ = _row_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _row_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			row = (DinoUiConversationSelectorRow*) _tmp8_;
			_tmp9_ = row;
			dino_ui_conversation_selector_row_update (_tmp9_);
			_g_object_unref0 (row);
		}
		_g_object_unref0 (_row_it);
	}
	result = TRUE;
	return result;
}

static gboolean
___lambda149__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda149_ ((DinoUiConversationSelector*) self);
	return result;
}

DinoUiConversationSelector*
dino_ui_conversation_selector_init (DinoUiConversationSelector* self,
                                    DinoStreamInteractor* stream_interactor)
{
	DinoStreamInteractor* _tmp0_;
	GtkListBox* _tmp1_;
	GtkBinLayout* _tmp2_;
	DinoModuleIdentity* _tmp3_;
	gpointer _tmp4_;
	DinoConversationManager* _tmp5_;
	DinoModuleIdentity* _tmp6_;
	gpointer _tmp7_;
	DinoConversationManager* _tmp8_;
	DinoModuleIdentity* _tmp9_;
	gpointer _tmp10_;
	DinoContentItemStore* _tmp11_;
	DinoUiConversationSelector* _tmp25_;
	DinoUiConversationSelector* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	_tmp1_ = self->priv->list_box;
	gtk_widget_set_parent ((GtkWidget*) _tmp1_, (GtkWidget*) self);
	_tmp2_ = (GtkBinLayout*) gtk_bin_layout_new ();
	gtk_widget_set_layout_manager ((GtkWidget*) self, (GtkLayoutManager*) _tmp2_);
	_tmp3_ = dino_conversation_manager_IDENTITY;
	_tmp4_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp3_);
	_tmp5_ = (DinoConversationManager*) _tmp4_;
	g_signal_connect_object (_tmp5_, "conversation-activated", (GCallback) _dino_ui_conversation_selector_add_conversation_dino_conversation_manager_conversation_activated, self, 0);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = dino_conversation_manager_IDENTITY;
	_tmp7_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp6_);
	_tmp8_ = (DinoConversationManager*) _tmp7_;
	g_signal_connect_object (_tmp8_, "conversation-deactivated", (GCallback) _dino_ui_conversation_selector_remove_conversation_dino_conversation_manager_conversation_deactivated, self, 0);
	_g_object_unref0 (_tmp8_);
	_tmp9_ = dino_content_item_store_IDENTITY;
	_tmp10_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_CONTENT_ITEM_STORE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp9_);
	_tmp11_ = (DinoContentItemStore*) _tmp10_;
	g_signal_connect_object (_tmp11_, "new-item", (GCallback) _dino_ui_conversation_selector_on_content_item_received_dino_content_item_store_new_item, self, 0);
	_g_object_unref0 (_tmp11_);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 60, ___lambda149__gsource_func, g_object_ref (self), g_object_unref);
	{
		GeeList* _conversation_list = NULL;
		DinoModuleIdentity* _tmp12_;
		gpointer _tmp13_;
		DinoConversationManager* _tmp14_;
		GeeList* _tmp15_;
		GeeList* _tmp16_;
		gint _conversation_size = 0;
		GeeList* _tmp17_;
		gint _tmp18_;
		gint _tmp19_;
		gint _conversation_index = 0;
		_tmp12_ = dino_conversation_manager_IDENTITY;
		_tmp13_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp12_);
		_tmp14_ = (DinoConversationManager*) _tmp13_;
		_tmp15_ = dino_conversation_manager_get_active_conversations (_tmp14_, NULL);
		_tmp16_ = _tmp15_;
		_g_object_unref0 (_tmp14_);
		_conversation_list = _tmp16_;
		_tmp17_ = _conversation_list;
		_tmp18_ = gee_collection_get_size ((GeeCollection*) _tmp17_);
		_tmp19_ = _tmp18_;
		_conversation_size = _tmp19_;
		_conversation_index = -1;
		while (TRUE) {
			gint _tmp20_;
			gint _tmp21_;
			DinoEntitiesConversation* conversation = NULL;
			GeeList* _tmp22_;
			gpointer _tmp23_;
			DinoEntitiesConversation* _tmp24_;
			_conversation_index = _conversation_index + 1;
			_tmp20_ = _conversation_index;
			_tmp21_ = _conversation_size;
			if (!(_tmp20_ < _tmp21_)) {
				break;
			}
			_tmp22_ = _conversation_list;
			_tmp23_ = gee_list_get (_tmp22_, _conversation_index);
			conversation = (DinoEntitiesConversation*) _tmp23_;
			_tmp24_ = conversation;
			dino_ui_conversation_selector_add_conversation (self, _tmp24_);
			_g_object_unref0 (conversation);
		}
		_g_object_unref0 (_conversation_list);
	}
	_tmp25_ = _g_object_ref0 (self);
	result = _tmp25_;
	return result;
}

void
dino_ui_conversation_selector_row_activated (DinoUiConversationSelector* self,
                                             GtkListBoxRow* r)
{
	DinoUiConversationSelectorRow* row = NULL;
	DinoUiConversationSelectorRow* _tmp0_;
	DinoUiConversationSelectorRow* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (r != NULL);
	_tmp0_ = _g_object_ref0 (DINO_UI_IS_CONVERSATION_SELECTOR_ROW (r) ? ((DinoUiConversationSelectorRow*) r) : NULL);
	row = _tmp0_;
	_tmp1_ = row;
	if (_tmp1_ != NULL) {
		DinoUiConversationSelectorRow* _tmp2_;
		DinoEntitiesConversation* _tmp3_;
		DinoEntitiesConversation* _tmp4_;
		_tmp2_ = row;
		_tmp3_ = dino_ui_conversation_selector_row_get_conversation (_tmp2_);
		_tmp4_ = _tmp3_;
		g_signal_emit (self, dino_ui_conversation_selector_signals[DINO_UI_CONVERSATION_SELECTOR_CONVERSATION_SELECTED_SIGNAL], 0, _tmp4_);
	}
	_g_object_unref0 (row);
}

void
dino_ui_conversation_selector_on_conversation_selected (DinoUiConversationSelector* self,
                                                        DinoEntitiesConversation* conversation)
{
	GeeHashMap* _tmp0_;
	GtkListBox* _tmp1_;
	GeeHashMap* _tmp2_;
	gpointer _tmp3_;
	DinoUiConversationSelectorRow* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = self->priv->rows;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, conversation)) {
		dino_ui_conversation_selector_add_conversation (self, conversation);
	}
	_tmp1_ = self->priv->list_box;
	_tmp2_ = self->priv->rows;
	_tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp2_, conversation);
	_tmp4_ = (DinoUiConversationSelectorRow*) _tmp3_;
	gtk_list_box_select_row (_tmp1_, (GtkListBoxRow*) _tmp4_);
	_g_object_unref0 (_tmp4_);
}

static void
dino_ui_conversation_selector_on_content_item_received (DinoUiConversationSelector* self,
                                                        DinoContentItem* item,
                                                        DinoEntitiesConversation* conversation)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = self->priv->rows;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, conversation)) {
		GtkListBox* _tmp1_;
		_tmp1_ = self->priv->list_box;
		gtk_list_box_invalidate_sort (_tmp1_);
	}
}

static Block49Data*
block49_data_ref (Block49Data* _data49_)
{
	g_atomic_int_inc (&_data49_->_ref_count_);
	return _data49_;
}

static void
block49_data_unref (void * _userdata_)
{
	Block49Data* _data49_;
	_data49_ = (Block49Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data49_->_ref_count_)) {
		DinoUiConversationSelector* self;
		self = _data49_->self;
		_g_object_unref0 (_data49_->conversation);
		_g_object_unref0 (self);
		g_slice_free (Block49Data, _data49_);
	}
}

static Block50Data*
block50_data_ref (Block50Data* _data50_)
{
	g_atomic_int_inc (&_data50_->_ref_count_);
	return _data50_;
}

static void
block50_data_unref (void * _userdata_)
{
	Block50Data* _data50_;
	_data50_ = (Block50Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data50_->_ref_count_)) {
		DinoUiConversationSelector* self;
		self = _data50_->_data49_->self;
		block49_data_unref (_data50_->_data49_);
		_data50_->_data49_ = NULL;
		g_slice_free (Block50Data, _data50_);
	}
}

static void
_gtk_list_box_invalidate_sort_g_object_notify (GObject* _sender,
                                               GParamSpec* pspec,
                                               gpointer self)
{
	gtk_list_box_invalidate_sort ((GtkListBox*) self);
}

static gboolean
__lambda147_ (Block50Data* _data50_)
{
	Block49Data* _data49_;
	DinoUiConversationSelector* self;
	gboolean result;
	_data49_ = _data50_->_data49_;
	self = _data49_->self;
	g_signal_emit (self, dino_ui_conversation_selector_signals[DINO_UI_CONVERSATION_SELECTOR_CONVERSATION_SELECTED_SIGNAL], 0, _data49_->conversation);
	_data50_->drag_timeout = (guint) 0;
	result = FALSE;
	return result;
}

static gboolean
___lambda147__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda147_ (self);
	return result;
}

static void
___lambda146_ (Block50Data* _data50_,
               gdouble x,
               gdouble y)
{
	Block49Data* _data49_;
	DinoUiConversationSelector* self;
	_data49_ = _data50_->_data49_;
	self = _data49_->self;
	if (_data50_->drag_timeout != ((guint) 0)) {
		return;
	}
	_data50_->drag_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 200, ___lambda147__gsource_func, block50_data_ref (_data50_), block50_data_unref);
}

static void
____lambda146__gtk_drop_controller_motion_motion (GtkDropControllerMotion* _sender,
                                                  gdouble x,
                                                  gdouble y,
                                                  gpointer self)
{
	___lambda146_ (self, x, y);
}

static void
___lambda148_ (Block50Data* _data50_)
{
	Block49Data* _data49_;
	DinoUiConversationSelector* self;
	_data49_ = _data50_->_data49_;
	self = _data49_->self;
	if (_data50_->drag_timeout != ((guint) 0)) {
		g_source_remove (_data50_->drag_timeout);
		_data50_->drag_timeout = (guint) 0;
	}
}

static void
____lambda148__gtk_drop_controller_motion_leave (GtkDropControllerMotion* _sender,
                                                 gpointer self)
{
	___lambda148_ (self);
}

static void
dino_ui_conversation_selector_add_conversation (DinoUiConversationSelector* self,
                                                DinoEntitiesConversation* conversation)
{
	Block49Data* _data49_;
	DinoEntitiesConversation* _tmp0_;
	DinoUiConversationSelectorRow* row = NULL;
	GeeHashMap* _tmp1_;
	GtkListBox* _tmp17_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_data49_ = g_slice_new0 (Block49Data);
	_data49_->_ref_count_ = 1;
	_data49_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data49_->conversation);
	_data49_->conversation = _tmp0_;
	_tmp1_ = self->priv->rows;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp1_, _data49_->conversation)) {
		Block50Data* _data50_;
		GtkListBox* _tmp2_;
		DinoStreamInteractor* _tmp3_;
		DinoUiConversationSelectorRow* _tmp4_;
		GeeHashMap* _tmp5_;
		DinoUiConversationSelectorRow* _tmp6_;
		GtkListBox* _tmp7_;
		DinoUiConversationSelectorRow* _tmp8_;
		DinoUiConversationSelectorRow* _tmp9_;
		GtkRevealer* _tmp10_;
		GtkDropControllerMotion* drop_motion_controller = NULL;
		GtkDropControllerMotion* _tmp11_;
		GtkDropControllerMotion* _tmp12_;
		GtkDropControllerMotion* _tmp13_;
		DinoUiConversationSelectorRow* _tmp14_;
		GtkDropControllerMotion* _tmp15_;
		GtkEventController* _tmp16_;
		_data50_ = g_slice_new0 (Block50Data);
		_data50_->_ref_count_ = 1;
		_data50_->_data49_ = block49_data_ref (_data49_);
		_tmp2_ = self->priv->list_box;
		g_signal_connect_object ((GObject*) _data49_->conversation, "notify::pinned", (GCallback) _gtk_list_box_invalidate_sort_g_object_notify, _tmp2_, 0);
		_tmp3_ = self->priv->stream_interactor;
		_tmp4_ = dino_ui_conversation_selector_row_new (_tmp3_, _data49_->conversation);
		g_object_ref_sink (_tmp4_);
		_g_object_unref0 (row);
		row = _tmp4_;
		_tmp5_ = self->priv->rows;
		_tmp6_ = row;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp5_, _data49_->conversation, _tmp6_);
		_tmp7_ = self->priv->list_box;
		_tmp8_ = row;
		gtk_list_box_append (_tmp7_, (GtkWidget*) _tmp8_);
		_tmp9_ = row;
		_tmp10_ = _tmp9_->main_revealer;
		gtk_revealer_set_reveal_child (_tmp10_, TRUE);
		_tmp11_ = (GtkDropControllerMotion*) gtk_drop_controller_motion_new ();
		drop_motion_controller = _tmp11_;
		_data50_->drag_timeout = (guint) 0;
		_tmp12_ = drop_motion_controller;
		g_signal_connect_data (_tmp12_, "motion", (GCallback) ____lambda146__gtk_drop_controller_motion_motion, block50_data_ref (_data50_), (GClosureNotify) block50_data_unref, 0);
		_tmp13_ = drop_motion_controller;
		g_signal_connect_data (_tmp13_, "leave", (GCallback) ____lambda148__gtk_drop_controller_motion_leave, block50_data_ref (_data50_), (GClosureNotify) block50_data_unref, 0);
		_tmp14_ = row;
		_tmp15_ = drop_motion_controller;
		_tmp16_ = _g_object_ref0 ((GtkEventController*) _tmp15_);
		gtk_widget_add_controller ((GtkWidget*) _tmp14_, _tmp16_);
		_g_object_unref0 (drop_motion_controller);
		block50_data_unref (_data50_);
		_data50_ = NULL;
	}
	_tmp17_ = self->priv->list_box;
	gtk_list_box_invalidate_sort (_tmp17_);
	_g_object_unref0 (row);
	block49_data_unref (_data49_);
	_data49_ = NULL;
}

static void
dino_ui_conversation_selector_select_fallback_conversation (DinoUiConversationSelector* self,
                                                            DinoEntitiesConversation* conversation)
{
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	GeeHashMap* _tmp2_;
	gpointer _tmp3_;
	DinoUiConversationSelectorRow* _tmp4_;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = self->priv->list_box;
	_tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
	_tmp2_ = self->priv->rows;
	_tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp2_, conversation);
	_tmp4_ = (DinoUiConversationSelectorRow*) _tmp3_;
	_tmp5_ = _tmp1_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_list_box_row_get_type (), GtkListBoxRow);
	_g_object_unref0 (_tmp4_);
	if (_tmp5_) {
		gint index = 0;
		GeeHashMap* _tmp6_;
		gpointer _tmp7_;
		DinoUiConversationSelectorRow* _tmp8_;
		gint _tmp9_;
		GtkListBoxRow* next_select_row = NULL;
		GtkListBox* _tmp10_;
		GtkListBoxRow* _tmp11_;
		GtkListBoxRow* _tmp12_;
		GtkListBoxRow* _tmp13_;
		GtkListBoxRow* _tmp17_;
		_tmp6_ = self->priv->rows;
		_tmp7_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp6_, conversation);
		_tmp8_ = (DinoUiConversationSelectorRow*) _tmp7_;
		_tmp9_ = gtk_list_box_row_get_index ((GtkListBoxRow*) _tmp8_);
		_g_object_unref0 (_tmp8_);
		index = _tmp9_;
		_tmp10_ = self->priv->list_box;
		_tmp11_ = gtk_list_box_get_row_at_index (_tmp10_, index + 1);
		_tmp12_ = _g_object_ref0 (_tmp11_);
		next_select_row = _tmp12_;
		_tmp13_ = next_select_row;
		if (_tmp13_ == NULL) {
			GtkListBox* _tmp14_;
			GtkListBoxRow* _tmp15_;
			GtkListBoxRow* _tmp16_;
			_tmp14_ = self->priv->list_box;
			_tmp15_ = gtk_list_box_get_row_at_index (_tmp14_, index - 1);
			_tmp16_ = _g_object_ref0 (_tmp15_);
			_g_object_unref0 (next_select_row);
			next_select_row = _tmp16_;
		}
		_tmp17_ = next_select_row;
		if (_tmp17_ != NULL) {
			GtkListBox* _tmp18_;
			GtkListBoxRow* _tmp19_;
			GtkListBoxRow* _tmp20_;
			_tmp18_ = self->priv->list_box;
			_tmp19_ = next_select_row;
			gtk_list_box_select_row (_tmp18_, _tmp19_);
			_tmp20_ = next_select_row;
			dino_ui_conversation_selector_row_activated (self, _tmp20_);
		}
		_g_object_unref0 (next_select_row);
	}
}

static void
dino_ui_conversation_selector_remove_conversation_data_free (gpointer _data)
{
	DinoUiConversationSelectorRemoveConversationData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoUiConversationSelectorRemoveConversationData, _data_);
}

static void
dino_ui_conversation_selector_remove_conversation (DinoUiConversationSelector* self,
                                                   DinoEntitiesConversation* conversation,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	DinoUiConversationSelectorRemoveConversationData* _data_;
	DinoUiConversationSelector* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_data_ = g_slice_new0 (DinoUiConversationSelectorRemoveConversationData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_ui_conversation_selector_remove_conversation_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp1_;
	dino_ui_conversation_selector_remove_conversation_co (_data_);
}

static void
dino_ui_conversation_selector_remove_conversation_finish (DinoUiConversationSelector* self,
                                                          GAsyncResult* _res_)
{
	DinoUiConversationSelectorRemoveConversationData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dino_ui_conversation_selector_remove_conversation_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_)
{
	DinoUiConversationSelectorRemoveConversationData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_ui_conversation_selector_remove_conversation_co (_data_);
}

static gboolean
dino_ui_conversation_selector_remove_conversation_co (DinoUiConversationSelectorRemoveConversationData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	dino_ui_conversation_selector_select_fallback_conversation (_data_->self, _data_->conversation);
	_data_->_tmp0_ = _data_->self->priv->rows;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _data_->_tmp0_, _data_->conversation)) {
		_data_->_tmp1_ = _data_->self->priv->list_box;
		g_signal_parse_name ("notify::pinned", G_TYPE_OBJECT, &_data_->_tmp2_, &_data_->_tmp3_, TRUE);
		g_signal_handlers_disconnect_matched ((GObject*) _data_->conversation, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp2_, _data_->_tmp3_, NULL, (GCallback) _gtk_list_box_invalidate_sort_g_object_notify, _data_->_tmp1_);
		_data_->_tmp4_ = _data_->self->priv->rows;
		_data_->_tmp5_ = NULL;
		gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp4_, _data_->conversation, &_data_->_tmp5_);
		_g_object_unref0 (_data_->conversation_row);
		_data_->conversation_row = (DinoUiConversationSelectorRow*) _data_->_tmp5_;
		_data_->_tmp6_ = _data_->conversation_row;
		_data_->_state_ = 1;
		dino_ui_conversation_selector_row_colapse (_data_->_tmp6_, dino_ui_conversation_selector_remove_conversation_ready, _data_);
		return FALSE;
		_state_1:
		dino_ui_conversation_selector_row_colapse_finish (_data_->_tmp6_, _data_->_res_);
		_data_->_tmp7_ = _data_->self->priv->list_box;
		_data_->_tmp8_ = _data_->conversation_row;
		gtk_list_box_remove (_data_->_tmp7_, (GtkWidget*) _data_->_tmp8_);
		_g_object_unref0 (_data_->conversation_row);
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
dino_ui_conversation_selector_loop_conversations (DinoUiConversationSelector* self,
                                                  gboolean backwards)
{
	gint index = 0;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	gint _tmp2_ = 0;
	gint new_index = 0;
	GeeHashMap* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	GeeHashMap* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	GtkListBoxRow* next_select_row = NULL;
	GtkListBox* _tmp9_;
	GtkListBoxRow* _tmp10_;
	GtkListBoxRow* _tmp11_;
	GtkListBoxRow* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->list_box;
	_tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
	index = gtk_list_box_row_get_index (_tmp1_);
	if (backwards) {
		_tmp2_ = -1;
	} else {
		_tmp2_ = 1;
	}
	_tmp3_ = self->priv->rows;
	_tmp4_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->priv->rows;
	_tmp7_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp6_);
	_tmp8_ = _tmp7_;
	new_index = ((index + _tmp2_) + _tmp5_) % _tmp8_;
	_tmp9_ = self->priv->list_box;
	_tmp10_ = gtk_list_box_get_row_at_index (_tmp9_, new_index);
	_tmp11_ = _g_object_ref0 (_tmp10_);
	next_select_row = _tmp11_;
	_tmp12_ = next_select_row;
	if (_tmp12_ != NULL) {
		GtkListBox* _tmp13_;
		GtkListBoxRow* _tmp14_;
		GtkListBoxRow* _tmp15_;
		_tmp13_ = self->priv->list_box;
		_tmp14_ = next_select_row;
		gtk_list_box_select_row (_tmp13_, _tmp14_);
		_tmp15_ = next_select_row;
		dino_ui_conversation_selector_row_activated (self, _tmp15_);
	}
	_g_object_unref0 (next_select_row);
}

static gint
dino_ui_conversation_selector_sort (DinoUiConversationSelector* self,
                                    GtkListBoxRow* row1,
                                    GtkListBoxRow* row2)
{
	DinoUiConversationSelectorRow* cr1 = NULL;
	DinoUiConversationSelectorRow* _tmp0_;
	DinoUiConversationSelectorRow* cr2 = NULL;
	DinoUiConversationSelectorRow* _tmp1_;
	gboolean _tmp2_ = FALSE;
	DinoUiConversationSelectorRow* _tmp3_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (row1 != NULL, -1);
	g_return_val_if_fail (row2 != NULL, -1);
	_tmp0_ = _g_object_ref0 (DINO_UI_IS_CONVERSATION_SELECTOR_ROW (row1) ? ((DinoUiConversationSelectorRow*) row1) : NULL);
	cr1 = _tmp0_;
	_tmp1_ = _g_object_ref0 (DINO_UI_IS_CONVERSATION_SELECTOR_ROW (row2) ? ((DinoUiConversationSelectorRow*) row2) : NULL);
	cr2 = _tmp1_;
	_tmp3_ = cr1;
	if (_tmp3_ != NULL) {
		DinoUiConversationSelectorRow* _tmp4_;
		_tmp4_ = cr2;
		_tmp2_ = _tmp4_ != NULL;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		DinoEntitiesConversation* c1 = NULL;
		DinoUiConversationSelectorRow* _tmp5_;
		DinoEntitiesConversation* _tmp6_;
		DinoEntitiesConversation* _tmp7_;
		DinoEntitiesConversation* _tmp8_;
		DinoEntitiesConversation* c2 = NULL;
		DinoUiConversationSelectorRow* _tmp9_;
		DinoEntitiesConversation* _tmp10_;
		DinoEntitiesConversation* _tmp11_;
		DinoEntitiesConversation* _tmp12_;
		gint pin_comp = 0;
		DinoEntitiesConversation* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		DinoEntitiesConversation* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		DinoEntitiesConversation* _tmp19_;
		GDateTime* _tmp20_;
		GDateTime* _tmp21_;
		DinoEntitiesConversation* _tmp22_;
		GDateTime* _tmp23_;
		GDateTime* _tmp24_;
		gint comp = 0;
		DinoEntitiesConversation* _tmp25_;
		GDateTime* _tmp26_;
		GDateTime* _tmp27_;
		DinoEntitiesConversation* _tmp28_;
		GDateTime* _tmp29_;
		GDateTime* _tmp30_;
		_tmp5_ = cr1;
		_tmp6_ = dino_ui_conversation_selector_row_get_conversation (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = _g_object_ref0 (_tmp7_);
		c1 = _tmp8_;
		_tmp9_ = cr2;
		_tmp10_ = dino_ui_conversation_selector_row_get_conversation (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = _g_object_ref0 (_tmp11_);
		c2 = _tmp12_;
		_tmp13_ = c2;
		_tmp14_ = dino_entities_conversation_get_pinned (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = c1;
		_tmp17_ = dino_entities_conversation_get_pinned (_tmp16_);
		_tmp18_ = _tmp17_;
		pin_comp = _tmp15_ - _tmp18_;
		if (pin_comp != 0) {
			result = pin_comp;
			_g_object_unref0 (c2);
			_g_object_unref0 (c1);
			_g_object_unref0 (cr2);
			_g_object_unref0 (cr1);
			return result;
		}
		_tmp19_ = c1;
		_tmp20_ = dino_entities_conversation_get_last_active (_tmp19_);
		_tmp21_ = _tmp20_;
		if (_tmp21_ == NULL) {
			result = -1;
			_g_object_unref0 (c2);
			_g_object_unref0 (c1);
			_g_object_unref0 (cr2);
			_g_object_unref0 (cr1);
			return result;
		}
		_tmp22_ = c2;
		_tmp23_ = dino_entities_conversation_get_last_active (_tmp22_);
		_tmp24_ = _tmp23_;
		if (_tmp24_ == NULL) {
			result = 1;
			_g_object_unref0 (c2);
			_g_object_unref0 (c1);
			_g_object_unref0 (cr2);
			_g_object_unref0 (cr1);
			return result;
		}
		_tmp25_ = c2;
		_tmp26_ = dino_entities_conversation_get_last_active (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = c1;
		_tmp29_ = dino_entities_conversation_get_last_active (_tmp28_);
		_tmp30_ = _tmp29_;
		comp = g_date_time_compare (_tmp27_, _tmp30_);
		if (comp == 0) {
			DinoStreamInteractor* _tmp31_;
			DinoEntitiesConversation* _tmp32_;
			gchar* _tmp33_;
			gchar* _tmp34_;
			DinoStreamInteractor* _tmp35_;
			DinoEntitiesConversation* _tmp36_;
			gchar* _tmp37_;
			gchar* _tmp38_;
			gint _tmp39_;
			_tmp31_ = self->priv->stream_interactor;
			_tmp32_ = c1;
			_tmp33_ = dino_ui_util_get_conversation_display_name (_tmp31_, _tmp32_);
			_tmp34_ = _tmp33_;
			_tmp35_ = self->priv->stream_interactor;
			_tmp36_ = c2;
			_tmp37_ = dino_ui_util_get_conversation_display_name (_tmp35_, _tmp36_);
			_tmp38_ = _tmp37_;
			_tmp39_ = g_utf8_collate (_tmp34_, _tmp38_);
			_g_free0 (_tmp38_);
			_g_free0 (_tmp34_);
			result = _tmp39_;
			_g_object_unref0 (c2);
			_g_object_unref0 (c1);
			_g_object_unref0 (cr2);
			_g_object_unref0 (cr1);
			return result;
		} else {
			result = comp;
			_g_object_unref0 (c2);
			_g_object_unref0 (c1);
			_g_object_unref0 (cr2);
			_g_object_unref0 (cr1);
			return result;
		}
		_g_object_unref0 (c2);
		_g_object_unref0 (c1);
	}
	result = 0;
	_g_object_unref0 (cr2);
	_g_object_unref0 (cr1);
	return result;
}

DinoUiConversationSelector*
dino_ui_conversation_selector_construct (GType object_type)
{
	DinoUiConversationSelector * self = NULL;
	self = (DinoUiConversationSelector*) g_object_new (object_type, NULL);
	return self;
}

DinoUiConversationSelector*
dino_ui_conversation_selector_new (void)
{
	return dino_ui_conversation_selector_construct (DINO_UI_TYPE_CONVERSATION_SELECTOR);
}

static gint
_dino_ui_conversation_selector_sort_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                            GtkListBoxRow* row2,
                                                            gpointer self)
{
	gint result;
	result = dino_ui_conversation_selector_sort ((DinoUiConversationSelector*) self, row1, row2);
	return result;
}

static void
_dino_ui_conversation_selector___lambda150_ (DinoUiConversationSelector* self)
{
	GtkListBoxRow* first_row = NULL;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	_tmp0_ = self->priv->list_box;
	_tmp1_ = gtk_list_box_get_row_at_index (_tmp0_, 0);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	first_row = _tmp2_;
	_tmp3_ = first_row;
	if (_tmp3_ != NULL) {
		GtkListBox* _tmp4_;
		GtkListBoxRow* _tmp5_;
		GtkListBoxRow* _tmp6_;
		_tmp4_ = self->priv->list_box;
		_tmp5_ = first_row;
		gtk_list_box_select_row (_tmp4_, _tmp5_);
		_tmp6_ = first_row;
		dino_ui_conversation_selector_row_activated (self, _tmp6_);
	}
	_g_object_unref0 (first_row);
}

static void
__dino_ui_conversation_selector___lambda150__gtk_widget_realize (GtkWidget* _sender,
                                                                 gpointer self)
{
	_dino_ui_conversation_selector___lambda150_ ((DinoUiConversationSelector*) self);
}

static void
_dino_ui_conversation_selector_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                         GtkListBoxRow* row,
                                                                         gpointer self)
{
	dino_ui_conversation_selector_row_activated ((DinoUiConversationSelector*) self, row);
}

static GObject *
dino_ui_conversation_selector_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DinoUiConversationSelector * self;
	GtkListBox* _tmp0_;
	GtkListBox* _tmp1_;
	parent_class = G_OBJECT_CLASS (dino_ui_conversation_selector_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_TYPE_CONVERSATION_SELECTOR, DinoUiConversationSelector);
	_tmp0_ = self->priv->list_box;
	gtk_list_box_set_sort_func (_tmp0_, _dino_ui_conversation_selector_sort_gtk_list_box_sort_func, g_object_ref (self), g_object_unref);
	g_signal_connect_object ((GtkWidget*) self, "realize", (GCallback) __dino_ui_conversation_selector___lambda150__gtk_widget_realize, self, 0);
	_tmp1_ = self->priv->list_box;
	g_signal_connect_object (_tmp1_, "row-activated", (GCallback) _dino_ui_conversation_selector_row_activated_gtk_list_box_row_activated, self, 0);
	return obj;
}

static void
dino_ui_conversation_selector_class_init (DinoUiConversationSelectorClass * klass,
                                          gpointer klass_data)
{
	dino_ui_conversation_selector_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiConversationSelector_private_offset);
	G_OBJECT_CLASS (klass)->constructor = dino_ui_conversation_selector_constructor;
	G_OBJECT_CLASS (klass)->finalize = dino_ui_conversation_selector_finalize;
	dino_ui_conversation_selector_signals[DINO_UI_CONVERSATION_SELECTOR_CONVERSATION_SELECTED_SIGNAL] = g_signal_new ("conversation-selected", DINO_UI_TYPE_CONVERSATION_SELECTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DINO_ENTITIES_TYPE_CONVERSATION);
}

static void
dino_ui_conversation_selector_instance_init (DinoUiConversationSelector * self,
                                             gpointer klass)
{
	GtkListBox* _tmp0_ = NULL;
	GeeHashMap* _tmp1_;
	self->priv = dino_ui_conversation_selector_get_instance_private (self);
	_tmp0_ = (GtkListBox*) gtk_list_box_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp0_, TRUE);
	g_object_ref_sink (_tmp0_);
	self->priv->list_box = _tmp0_;
	_tmp1_ = gee_hash_map_new (DINO_ENTITIES_TYPE_CONVERSATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, DINO_UI_TYPE_CONVERSATION_SELECTOR_ROW, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _dino_entities_conversation_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_conversation_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->rows = _tmp1_;
}

static void
dino_ui_conversation_selector_finalize (GObject * obj)
{
	DinoUiConversationSelector * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_TYPE_CONVERSATION_SELECTOR, DinoUiConversationSelector);
	_g_object_unref0 (self->priv->list_box);
	_g_object_unref0 (self->priv->stream_interactor);
	_g_object_unref0 (self->priv->rows);
	G_OBJECT_CLASS (dino_ui_conversation_selector_parent_class)->finalize (obj);
}

static GType
dino_ui_conversation_selector_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiConversationSelectorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_conversation_selector_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiConversationSelector), 0, (GInstanceInitFunc) dino_ui_conversation_selector_instance_init, NULL };
	GType dino_ui_conversation_selector_type_id;
	dino_ui_conversation_selector_type_id = g_type_register_static (gtk_widget_get_type (), "DinoUiConversationSelector", &g_define_type_info, 0);
	DinoUiConversationSelector_private_offset = g_type_add_instance_private (dino_ui_conversation_selector_type_id, sizeof (DinoUiConversationSelectorPrivate));
	return dino_ui_conversation_selector_type_id;
}

GType
dino_ui_conversation_selector_get_type (void)
{
	static volatile gsize dino_ui_conversation_selector_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_conversation_selector_type_id__once)) {
		GType dino_ui_conversation_selector_type_id;
		dino_ui_conversation_selector_type_id = dino_ui_conversation_selector_get_type_once ();
		g_once_init_leave (&dino_ui_conversation_selector_type_id__once, dino_ui_conversation_selector_type_id);
	}
	return dino_ui_conversation_selector_type_id__once;
}

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

