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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <gee.h>
#include "libdino.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "xmpp-vala.h"
#include "dino_i18n.h"
#include <float.h>
#include <math.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_OCCUPANT_MENU_TYPE_LIST (dino_ui_occupant_menu_list_get_type ())
#define DINO_UI_OCCUPANT_MENU_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_OCCUPANT_MENU_TYPE_LIST, DinoUiOccupantMenuList))
#define DINO_UI_OCCUPANT_MENU_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_OCCUPANT_MENU_TYPE_LIST, DinoUiOccupantMenuListClass))
#define DINO_UI_OCCUPANT_MENU_IS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_OCCUPANT_MENU_TYPE_LIST))
#define DINO_UI_OCCUPANT_MENU_IS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_OCCUPANT_MENU_TYPE_LIST))
#define DINO_UI_OCCUPANT_MENU_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_OCCUPANT_MENU_TYPE_LIST, DinoUiOccupantMenuListClass))

typedef struct _DinoUiOccupantMenuList DinoUiOccupantMenuList;
typedef struct _DinoUiOccupantMenuListClass DinoUiOccupantMenuListClass;
typedef struct _DinoUiOccupantMenuListPrivate DinoUiOccupantMenuListPrivate;

#define DINO_UI_OCCUPANT_MENU_TYPE_LIST_ROW (dino_ui_occupant_menu_list_row_get_type ())
#define DINO_UI_OCCUPANT_MENU_LIST_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_OCCUPANT_MENU_TYPE_LIST_ROW, DinoUiOccupantMenuListRow))
#define DINO_UI_OCCUPANT_MENU_LIST_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_OCCUPANT_MENU_TYPE_LIST_ROW, DinoUiOccupantMenuListRowClass))
#define DINO_UI_OCCUPANT_MENU_IS_LIST_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_OCCUPANT_MENU_TYPE_LIST_ROW))
#define DINO_UI_OCCUPANT_MENU_IS_LIST_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_OCCUPANT_MENU_TYPE_LIST_ROW))
#define DINO_UI_OCCUPANT_MENU_LIST_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_OCCUPANT_MENU_TYPE_LIST_ROW, DinoUiOccupantMenuListRowClass))

typedef struct _DinoUiOccupantMenuListRow DinoUiOccupantMenuListRow;
typedef struct _DinoUiOccupantMenuListRowClass DinoUiOccupantMenuListRowClass;
enum  {
	DINO_UI_OCCUPANT_MENU_LIST_0_PROPERTY,
	DINO_UI_OCCUPANT_MENU_LIST_NUM_PROPERTIES
};
static GParamSpec* dino_ui_occupant_menu_list_properties[DINO_UI_OCCUPANT_MENU_LIST_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _DinoUiOccupantMenuListRowPrivate DinoUiOccupantMenuListRowPrivate;
enum  {
	DINO_UI_OCCUPANT_MENU_LIST_CONVERSATION_SELECTED_SIGNAL,
	DINO_UI_OCCUPANT_MENU_LIST_NUM_SIGNALS
};
static guint dino_ui_occupant_menu_list_signals[DINO_UI_OCCUPANT_MENU_LIST_NUM_SIGNALS] = {0};

struct _DinoUiOccupantMenuList {
	GtkBox parent_instance;
	DinoUiOccupantMenuListPrivate * priv;
	GtkListBox* list_box;
	GeeHashMap* row_wrappers;
};

struct _DinoUiOccupantMenuListClass {
	GtkBoxClass parent_class;
};

struct _DinoUiOccupantMenuListPrivate {
	DinoStreamInteractor* stream_interactor;
	GtkSearchEntry* search_entry;
	DinoEntitiesConversation* conversation;
	gchar** filter_values;
	gint filter_values_length1;
	gint _filter_values_size_;
	GeeHashMap* rows;
};

struct _DinoUiOccupantMenuListRow {
	GObject parent_instance;
	DinoUiOccupantMenuListRowPrivate * priv;
	GtkLabel* name_label;
	DinoEntitiesConversation* conversation;
	XmppJid* jid;
};

struct _DinoUiOccupantMenuListRowClass {
	GObjectClass parent_class;
};

static gint DinoUiOccupantMenuList_private_offset;
static gpointer dino_ui_occupant_menu_list_parent_class = NULL;

VALA_EXTERN GType dino_ui_occupant_menu_list_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiOccupantMenuList, g_object_unref)
VALA_EXTERN GType dino_ui_occupant_menu_list_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiOccupantMenuListRow, g_object_unref)
static guint _xmpp_jid_hash_func_gee_hash_data_func (gconstpointer v,
                                              gpointer self);
static gboolean _xmpp_jid_equals_func_gee_equal_data_func (gconstpointer a,
                                                    gconstpointer b,
                                                    gpointer self);
VALA_EXTERN DinoUiOccupantMenuList* dino_ui_occupant_menu_list_new (DinoStreamInteractor* stream_interactor,
                                                        DinoEntitiesConversation* conversation);
VALA_EXTERN DinoUiOccupantMenuList* dino_ui_occupant_menu_list_construct (GType object_type,
                                                              DinoStreamInteractor* stream_interactor,
                                                              DinoEntitiesConversation* conversation);
static void dino_ui_occupant_menu_list_header (DinoUiOccupantMenuList* self,
                                        GtkListBoxRow* row,
                                        GtkListBoxRow* before_row);
static void _dino_ui_occupant_menu_list_header_gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                         GtkListBoxRow* before,
                                                                         gpointer self);
static gint dino_ui_occupant_menu_list_sort (DinoUiOccupantMenuList* self,
                                      GtkListBoxRow* row1,
                                      GtkListBoxRow* row2);
static gint _dino_ui_occupant_menu_list_sort_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                              GtkListBoxRow* row2,
                                                              gpointer self);
static gboolean dino_ui_occupant_menu_list_filter (DinoUiOccupantMenuList* self,
                                            GtkListBoxRow* r);
static gboolean _dino_ui_occupant_menu_list_filter_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                                      gpointer self);
static void dino_ui_occupant_menu_list_refilter (DinoUiOccupantMenuList* self);
static void _dino_ui_occupant_menu_list_refilter_gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                           gpointer self);
static void dino_ui_occupant_menu_list_on_show_received (DinoUiOccupantMenuList* self,
                                                  XmppJid* jid,
                                                  DinoEntitiesAccount* account);
static void _dino_ui_occupant_menu_list_on_show_received_dino_presence_manager_show_received (DinoPresenceManager* _sender,
                                                                                       XmppJid* jid,
                                                                                       DinoEntitiesAccount* account,
                                                                                       gpointer self);
static void dino_ui_occupant_menu_list_on_received_offline_presence (DinoUiOccupantMenuList* self,
                                                              XmppJid* jid,
                                                              DinoEntitiesAccount* account);
static void _dino_ui_occupant_menu_list_on_received_offline_presence_dino_presence_manager_received_offline_presence (DinoPresenceManager* _sender,
                                                                                                               XmppJid* jid,
                                                                                                               DinoEntitiesAccount* account,
                                                                                                               gpointer self);
VALA_EXTERN void dino_ui_occupant_menu_list_initialize_for_conversation (DinoUiOccupantMenuList* self,
                                                             DinoEntitiesConversation* conversation);
VALA_EXTERN void dino_ui_occupant_menu_list_add_occupant (DinoUiOccupantMenuList* self,
                                              XmppJid* jid);
static gchar** _vala_array_dup3 (gchar** self,
                          gssize length);
VALA_EXTERN DinoUiOccupantMenuListRow* dino_ui_occupant_menu_list_row_new (DinoStreamInteractor* stream_interactor,
                                                               DinoEntitiesConversation* conversation,
                                                               XmppJid* jid);
VALA_EXTERN DinoUiOccupantMenuListRow* dino_ui_occupant_menu_list_row_construct (GType object_type,
                                                                     DinoStreamInteractor* stream_interactor,
                                                                     DinoEntitiesConversation* conversation,
                                                                     XmppJid* jid);
VALA_EXTERN GtkWidget* dino_ui_occupant_menu_list_row_get_widget (DinoUiOccupantMenuListRow* self);
VALA_EXTERN void dino_ui_occupant_menu_list_remove_occupant (DinoUiOccupantMenuList* self,
                                                 XmppJid* jid);
static gboolean _xmpp_xep_muc_affiliation_equal (const XmppXepMucAffiliation * s1,
                                          const XmppXepMucAffiliation * s2);
static GtkWidget* dino_ui_occupant_menu_list_generate_header_widget (DinoUiOccupantMenuList* self,
                                                              XmppXepMucAffiliation affiliation,
                                                              gboolean top);
static XmppXepMucAffiliation* _xmpp_xep_muc_affiliation_dup (XmppXepMucAffiliation* self);
static gint dino_ui_occupant_menu_list_get_affiliation_ranking (DinoUiOccupantMenuList* self,
                                                         XmppXepMucAffiliation affiliation);
static void dino_ui_occupant_menu_list_finalize (GObject * obj);
static GType dino_ui_occupant_menu_list_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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_ui_occupant_menu_list_get_instance_private (DinoUiOccupantMenuList* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiOccupantMenuList_private_offset);
}

static guint
_xmpp_jid_hash_func_gee_hash_data_func (gconstpointer v,
                                        gpointer self)
{
	guint result;
	result = xmpp_jid_hash_func ((XmppJid*) v);
	return result;
}

static gboolean
_xmpp_jid_equals_func_gee_equal_data_func (gconstpointer a,
                                           gconstpointer b,
                                           gpointer self)
{
	gboolean result;
	result = xmpp_jid_equals_func ((XmppJid*) a, (XmppJid*) b);
	return result;
}

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

static void
_dino_ui_occupant_menu_list_header_gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                    GtkListBoxRow* before,
                                                                    gpointer self)
{
	dino_ui_occupant_menu_list_header ((DinoUiOccupantMenuList*) self, row, before);
}

static gint
_dino_ui_occupant_menu_list_sort_gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                         GtkListBoxRow* row2,
                                                         gpointer self)
{
	gint result;
	result = dino_ui_occupant_menu_list_sort ((DinoUiOccupantMenuList*) self, row1, row2);
	return result;
}

static gboolean
_dino_ui_occupant_menu_list_filter_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                             gpointer self)
{
	gboolean result;
	result = dino_ui_occupant_menu_list_filter ((DinoUiOccupantMenuList*) self, row);
	return result;
}

static void
_dino_ui_occupant_menu_list_refilter_gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                      gpointer self)
{
	dino_ui_occupant_menu_list_refilter ((DinoUiOccupantMenuList*) self);
}

static void
_dino_ui_occupant_menu_list_on_show_received_dino_presence_manager_show_received (DinoPresenceManager* _sender,
                                                                                  XmppJid* jid,
                                                                                  DinoEntitiesAccount* account,
                                                                                  gpointer self)
{
	dino_ui_occupant_menu_list_on_show_received ((DinoUiOccupantMenuList*) self, jid, account);
}

static void
_dino_ui_occupant_menu_list_on_received_offline_presence_dino_presence_manager_received_offline_presence (DinoPresenceManager* _sender,
                                                                                                          XmppJid* jid,
                                                                                                          DinoEntitiesAccount* account,
                                                                                                          gpointer self)
{
	dino_ui_occupant_menu_list_on_received_offline_presence ((DinoUiOccupantMenuList*) self, jid, account);
}

DinoUiOccupantMenuList*
dino_ui_occupant_menu_list_construct (GType object_type,
                                      DinoStreamInteractor* stream_interactor,
                                      DinoEntitiesConversation* conversation)
{
	DinoUiOccupantMenuList * self = NULL;
	DinoStreamInteractor* _tmp0_;
	GtkListBox* _tmp1_;
	GtkListBox* _tmp2_;
	GtkListBox* _tmp3_;
	GtkSearchEntry* _tmp4_;
	DinoModuleIdentity* _tmp5_;
	gpointer _tmp6_;
	DinoPresenceManager* _tmp7_;
	DinoModuleIdentity* _tmp8_;
	gpointer _tmp9_;
	DinoPresenceManager* _tmp10_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (conversation != NULL, NULL);
	self = (DinoUiOccupantMenuList*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	_tmp1_ = self->list_box;
	gtk_list_box_set_header_func (_tmp1_, _dino_ui_occupant_menu_list_header_gtk_list_box_update_header_func, g_object_ref (self), g_object_unref);
	_tmp2_ = self->list_box;
	gtk_list_box_set_sort_func (_tmp2_, _dino_ui_occupant_menu_list_sort_gtk_list_box_sort_func, g_object_ref (self), g_object_unref);
	_tmp3_ = self->list_box;
	gtk_list_box_set_filter_func (_tmp3_, _dino_ui_occupant_menu_list_filter_gtk_list_box_filter_func, g_object_ref (self), g_object_unref);
	_tmp4_ = self->priv->search_entry;
	g_signal_connect_object (_tmp4_, "search-changed", (GCallback) _dino_ui_occupant_menu_list_refilter_gtk_search_entry_search_changed, self, 0);
	_tmp5_ = dino_presence_manager_IDENTITY;
	_tmp6_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_PRESENCE_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp5_);
	_tmp7_ = (DinoPresenceManager*) _tmp6_;
	g_signal_connect_object (_tmp7_, "show-received", (GCallback) _dino_ui_occupant_menu_list_on_show_received_dino_presence_manager_show_received, self, 0);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = dino_presence_manager_IDENTITY;
	_tmp9_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_PRESENCE_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp8_);
	_tmp10_ = (DinoPresenceManager*) _tmp9_;
	g_signal_connect_object (_tmp10_, "received-offline-presence", (GCallback) _dino_ui_occupant_menu_list_on_received_offline_presence_dino_presence_manager_received_offline_presence, self, 0);
	_g_object_unref0 (_tmp10_);
	dino_ui_occupant_menu_list_initialize_for_conversation (self, conversation);
	return self;
}

DinoUiOccupantMenuList*
dino_ui_occupant_menu_list_new (DinoStreamInteractor* stream_interactor,
                                DinoEntitiesConversation* conversation)
{
	return dino_ui_occupant_menu_list_construct (DINO_UI_OCCUPANT_MENU_TYPE_LIST, stream_interactor, conversation);
}

void
dino_ui_occupant_menu_list_initialize_for_conversation (DinoUiOccupantMenuList* self,
                                                        DinoEntitiesConversation* conversation)
{
	DinoEntitiesConversation* _tmp0_;
	GeeList* occupants = NULL;
	DinoStreamInteractor* _tmp1_;
	DinoModuleIdentity* _tmp2_;
	gpointer _tmp3_;
	DinoMucManager* _tmp4_;
	XmppJid* _tmp5_;
	XmppJid* _tmp6_;
	DinoEntitiesAccount* _tmp7_;
	DinoEntitiesAccount* _tmp8_;
	GeeList* _tmp9_;
	GeeList* _tmp10_;
	GeeList* _tmp11_;
	GtkListBox* _tmp21_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = _g_object_ref0 (conversation);
	_g_object_unref0 (self->priv->conversation);
	self->priv->conversation = _tmp0_;
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = dino_muc_manager_IDENTITY;
	_tmp3_ = dino_stream_interactor_get_module (_tmp1_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
	_tmp4_ = (DinoMucManager*) _tmp3_;
	_tmp5_ = dino_entities_conversation_get_counterpart (conversation);
	_tmp6_ = _tmp5_;
	_tmp7_ = dino_entities_conversation_get_account (conversation);
	_tmp8_ = _tmp7_;
	_tmp9_ = dino_muc_manager_get_occupants (_tmp4_, _tmp6_, _tmp8_);
	_tmp10_ = _tmp9_;
	_g_object_unref0 (_tmp4_);
	occupants = _tmp10_;
	_tmp11_ = occupants;
	if (_tmp11_ != NULL) {
		{
			GeeList* _occupant_list = NULL;
			GeeList* _tmp12_;
			gint _occupant_size = 0;
			GeeList* _tmp13_;
			gint _tmp14_;
			gint _tmp15_;
			gint _occupant_index = 0;
			_tmp12_ = occupants;
			_occupant_list = _tmp12_;
			_tmp13_ = _occupant_list;
			_tmp14_ = gee_collection_get_size ((GeeCollection*) _tmp13_);
			_tmp15_ = _tmp14_;
			_occupant_size = _tmp15_;
			_occupant_index = -1;
			while (TRUE) {
				gint _tmp16_;
				gint _tmp17_;
				XmppJid* occupant = NULL;
				GeeList* _tmp18_;
				gpointer _tmp19_;
				XmppJid* _tmp20_;
				_occupant_index = _occupant_index + 1;
				_tmp16_ = _occupant_index;
				_tmp17_ = _occupant_size;
				if (!(_tmp16_ < _tmp17_)) {
					break;
				}
				_tmp18_ = _occupant_list;
				_tmp19_ = gee_list_get (_tmp18_, _occupant_index);
				occupant = (XmppJid*) _tmp19_;
				_tmp20_ = occupant;
				dino_ui_occupant_menu_list_add_occupant (self, _tmp20_);
				_xmpp_jid_unref0 (occupant);
			}
		}
	}
	_tmp21_ = self->list_box;
	gtk_list_box_invalidate_filter (_tmp21_);
	_g_object_unref0 (occupants);
}

static gchar**
_vala_array_dup3 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
dino_ui_occupant_menu_list_refilter (DinoUiOccupantMenuList* self)
{
	gchar** values = NULL;
	gint values_length1;
	gint _values_size_;
	gchar* str = NULL;
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gchar** _tmp9_;
	gint _tmp9__length1;
	gchar** _tmp10_;
	gint _tmp10__length1;
	GtkListBox* _tmp11_;
	g_return_if_fail (self != NULL);
	values = NULL;
	values_length1 = 0;
	_values_size_ = values_length1;
	_tmp0_ = self->priv->search_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	str = _tmp2_;
	_tmp3_ = str;
	if (g_strcmp0 (_tmp3_, "") != 0) {
		const gchar* _tmp4_;
		gchar** _tmp5_;
		gchar** _tmp6_;
		_tmp4_ = str;
		_tmp6_ = _tmp5_ = g_strsplit (_tmp4_, " ", 0);
		values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
		values = _tmp6_;
		values_length1 = _vala_array_length (_tmp5_);
		_values_size_ = values_length1;
	}
	_tmp7_ = self->priv->filter_values;
	_tmp7__length1 = self->priv->filter_values_length1;
	_tmp8_ = values;
	_tmp8__length1 = values_length1;
	if (_tmp7_ == _tmp8_) {
		_g_free0 (str);
		values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	_tmp9_ = values;
	_tmp9__length1 = values_length1;
	_tmp10_ = (_tmp9_ != NULL) ? _vala_array_dup3 (_tmp9_, _tmp9__length1) : _tmp9_;
	_tmp10__length1 = _tmp9__length1;
	self->priv->filter_values = (_vala_array_free (self->priv->filter_values, self->priv->filter_values_length1, (GDestroyNotify) g_free), NULL);
	self->priv->filter_values = _tmp10_;
	self->priv->filter_values_length1 = _tmp10__length1;
	self->priv->_filter_values_size_ = self->priv->filter_values_length1;
	_tmp11_ = self->list_box;
	gtk_list_box_invalidate_filter (_tmp11_);
	_g_free0 (str);
	values = (_vala_array_free (values, values_length1, (GDestroyNotify) g_free), NULL);
}

void
dino_ui_occupant_menu_list_add_occupant (DinoUiOccupantMenuList* self,
                                         XmppJid* jid)
{
	DinoUiOccupantMenuListRow* row_wrapper = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	DinoUiOccupantMenuListRow* _tmp2_;
	GtkWidget* widget = NULL;
	GtkWidget* _tmp3_;
	GeeHashMap* _tmp4_;
	GeeHashMap* _tmp5_;
	GtkListBox* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = self->priv->conversation;
	_tmp2_ = dino_ui_occupant_menu_list_row_new (_tmp0_, _tmp1_, jid);
	row_wrapper = _tmp2_;
	_tmp3_ = dino_ui_occupant_menu_list_row_get_widget (row_wrapper);
	widget = _tmp3_;
	_tmp4_ = self->row_wrappers;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp4_, widget, row_wrapper);
	_tmp5_ = self->priv->rows;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp5_, jid, widget);
	_tmp6_ = self->list_box;
	gtk_list_box_append (_tmp6_, widget);
	_g_object_unref0 (widget);
	_g_object_unref0 (row_wrapper);
}

void
dino_ui_occupant_menu_list_remove_occupant (DinoUiOccupantMenuList* self,
                                            XmppJid* jid)
{
	GtkListBox* _tmp0_;
	GeeHashMap* _tmp1_;
	gpointer _tmp2_;
	GtkWidget* _tmp3_;
	GeeHashMap* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = self->list_box;
	_tmp1_ = self->priv->rows;
	_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, jid);
	_tmp3_ = (GtkWidget*) _tmp2_;
	gtk_list_box_remove (_tmp0_, _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->rows;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp4_, jid, NULL);
}

static void
dino_ui_occupant_menu_list_on_received_offline_presence (DinoUiOccupantMenuList* self,
                                                         XmppJid* jid,
                                                         DinoEntitiesAccount* account)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	DinoEntitiesConversation* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (account != NULL);
	_tmp2_ = self->priv->conversation;
	if (_tmp2_ != NULL) {
		DinoEntitiesConversation* _tmp3_;
		XmppJid* _tmp4_;
		XmppJid* _tmp5_;
		_tmp3_ = self->priv->conversation;
		_tmp4_ = dino_entities_conversation_get_counterpart (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp1_ = xmpp_jid_equals_bare (_tmp5_, jid);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = xmpp_jid_is_full (jid);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GeeHashMap* _tmp6_;
		GtkListBox* _tmp7_;
		_tmp6_ = self->priv->rows;
		if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp6_, jid)) {
			dino_ui_occupant_menu_list_remove_occupant (self, jid);
		}
		_tmp7_ = self->list_box;
		gtk_list_box_invalidate_filter (_tmp7_);
	}
}

static void
dino_ui_occupant_menu_list_on_show_received (DinoUiOccupantMenuList* self,
                                             XmppJid* jid,
                                             DinoEntitiesAccount* account)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	DinoEntitiesConversation* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (account != NULL);
	_tmp2_ = self->priv->conversation;
	if (_tmp2_ != NULL) {
		DinoEntitiesConversation* _tmp3_;
		XmppJid* _tmp4_;
		XmppJid* _tmp5_;
		_tmp3_ = self->priv->conversation;
		_tmp4_ = dino_entities_conversation_get_counterpart (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp1_ = xmpp_jid_equals_bare (_tmp5_, jid);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = xmpp_jid_is_full (jid);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GeeHashMap* _tmp6_;
		GtkListBox* _tmp7_;
		_tmp6_ = self->priv->rows;
		if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp6_, jid)) {
			dino_ui_occupant_menu_list_add_occupant (self, jid);
		}
		_tmp7_ = self->list_box;
		gtk_list_box_invalidate_filter (_tmp7_);
	}
}

static gboolean
_xmpp_xep_muc_affiliation_equal (const XmppXepMucAffiliation * s1,
                                 const XmppXepMucAffiliation * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

static void
dino_ui_occupant_menu_list_header (DinoUiOccupantMenuList* self,
                                   GtkListBoxRow* row,
                                   GtkListBoxRow* before_row)
{
	DinoUiOccupantMenuListRow* row_wrapper1 = NULL;
	GeeHashMap* _tmp0_;
	GtkWidget* _tmp1_;
	gpointer _tmp2_;
	XmppXepMucAffiliation* a1 = NULL;
	DinoStreamInteractor* _tmp3_;
	DinoModuleIdentity* _tmp4_;
	gpointer _tmp5_;
	DinoMucManager* _tmp6_;
	DinoEntitiesConversation* _tmp7_;
	XmppJid* _tmp8_;
	XmppJid* _tmp9_;
	DinoUiOccupantMenuListRow* _tmp10_;
	XmppJid* _tmp11_;
	DinoUiOccupantMenuListRow* _tmp12_;
	DinoEntitiesConversation* _tmp13_;
	DinoEntitiesAccount* _tmp14_;
	DinoEntitiesAccount* _tmp15_;
	XmppXepMucAffiliation* _tmp16_;
	XmppXepMucAffiliation* _tmp17_;
	XmppXepMucAffiliation* _tmp18_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	_tmp0_ = self->row_wrappers;
	_tmp1_ = gtk_list_box_row_get_child (row);
	_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_);
	row_wrapper1 = (DinoUiOccupantMenuListRow*) _tmp2_;
	_tmp3_ = self->priv->stream_interactor;
	_tmp4_ = dino_muc_manager_IDENTITY;
	_tmp5_ = dino_stream_interactor_get_module (_tmp3_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp4_);
	_tmp6_ = (DinoMucManager*) _tmp5_;
	_tmp7_ = self->priv->conversation;
	_tmp8_ = dino_entities_conversation_get_counterpart (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = row_wrapper1;
	_tmp11_ = _tmp10_->jid;
	_tmp12_ = row_wrapper1;
	_tmp13_ = _tmp12_->conversation;
	_tmp14_ = dino_entities_conversation_get_account (_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = dino_muc_manager_get_affiliation (_tmp6_, _tmp9_, _tmp11_, _tmp15_);
	_tmp17_ = _tmp16_;
	_g_object_unref0 (_tmp6_);
	a1 = _tmp17_;
	_tmp18_ = a1;
	if (_tmp18_ == NULL) {
		_g_free0 (a1);
		_g_object_unref0 (row_wrapper1);
		return;
	}
	if (before_row != NULL) {
		DinoUiOccupantMenuListRow* row_wrapper2 = NULL;
		GeeHashMap* _tmp19_;
		GtkWidget* _tmp20_;
		gpointer _tmp21_;
		XmppXepMucAffiliation* a2 = NULL;
		DinoStreamInteractor* _tmp22_;
		DinoModuleIdentity* _tmp23_;
		gpointer _tmp24_;
		DinoMucManager* _tmp25_;
		DinoEntitiesConversation* _tmp26_;
		XmppJid* _tmp27_;
		XmppJid* _tmp28_;
		DinoUiOccupantMenuListRow* _tmp29_;
		XmppJid* _tmp30_;
		DinoUiOccupantMenuListRow* _tmp31_;
		DinoEntitiesConversation* _tmp32_;
		DinoEntitiesAccount* _tmp33_;
		DinoEntitiesAccount* _tmp34_;
		XmppXepMucAffiliation* _tmp35_;
		XmppXepMucAffiliation* _tmp36_;
		XmppXepMucAffiliation* _tmp37_;
		XmppXepMucAffiliation* _tmp38_;
		_tmp19_ = self->row_wrappers;
		_tmp20_ = gtk_list_box_row_get_child (before_row);
		_tmp21_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp19_, _tmp20_);
		row_wrapper2 = (DinoUiOccupantMenuListRow*) _tmp21_;
		_tmp22_ = self->priv->stream_interactor;
		_tmp23_ = dino_muc_manager_IDENTITY;
		_tmp24_ = dino_stream_interactor_get_module (_tmp22_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp23_);
		_tmp25_ = (DinoMucManager*) _tmp24_;
		_tmp26_ = self->priv->conversation;
		_tmp27_ = dino_entities_conversation_get_counterpart (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp29_ = row_wrapper2;
		_tmp30_ = _tmp29_->jid;
		_tmp31_ = row_wrapper2;
		_tmp32_ = _tmp31_->conversation;
		_tmp33_ = dino_entities_conversation_get_account (_tmp32_);
		_tmp34_ = _tmp33_;
		_tmp35_ = dino_muc_manager_get_affiliation (_tmp25_, _tmp28_, _tmp30_, _tmp34_);
		_tmp36_ = _tmp35_;
		_g_object_unref0 (_tmp25_);
		a2 = _tmp36_;
		_tmp37_ = a1;
		_tmp38_ = a2;
		if (_xmpp_xep_muc_affiliation_equal (_tmp37_, _tmp38_) != TRUE) {
			XmppXepMucAffiliation* _tmp39_;
			GtkWidget* _tmp40_;
			GtkWidget* _tmp41_;
			_tmp39_ = a1;
			_tmp40_ = dino_ui_occupant_menu_list_generate_header_widget (self, *_tmp39_, FALSE);
			_tmp41_ = _tmp40_;
			gtk_list_box_row_set_header (row, _tmp41_);
			_g_object_unref0 (_tmp41_);
		} else {
			GtkWidget* _tmp42_;
			_tmp42_ = gtk_list_box_row_get_header (row);
			if (_tmp42_ != NULL) {
				gtk_list_box_row_set_header (row, NULL);
			}
		}
		_g_free0 (a2);
		_g_object_unref0 (row_wrapper2);
	} else {
		XmppXepMucAffiliation* _tmp43_;
		GtkWidget* _tmp44_;
		GtkWidget* _tmp45_;
		_tmp43_ = a1;
		_tmp44_ = dino_ui_occupant_menu_list_generate_header_widget (self, *_tmp43_, TRUE);
		_tmp45_ = _tmp44_;
		gtk_list_box_row_set_header (row, _tmp45_);
		_g_object_unref0 (_tmp45_);
	}
	_g_free0 (a1);
	_g_object_unref0 (row_wrapper1);
}

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 GtkWidget*
dino_ui_occupant_menu_list_generate_header_widget (DinoUiOccupantMenuList* self,
                                                   XmppXepMucAffiliation affiliation,
                                                   gboolean top)
{
	gchar* aff_str = NULL;
	gint count = 0;
	GtkLabel* title_label = NULL;
	GtkLabel* _tmp33_ = NULL;
	GtkLabel* _tmp34_;
	const gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	const gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	GtkLabel* count_label = NULL;
	gchar* _tmp41_;
	gchar* _tmp42_;
	GtkLabel* _tmp43_ = NULL;
	GtkLabel* _tmp44_;
	GtkLabel* _tmp45_;
	gint _tmp46_ = 0;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp47_ = NULL;
	GtkLabel* _tmp48_;
	GtkLabel* _tmp49_;
	GtkSeparator* _tmp50_ = NULL;
	GtkSeparator* _tmp51_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	switch (affiliation) {
		case XMPP_XEP_MUC_AFFILIATION_OWNER:
		{
			const gchar* _tmp0_;
			gchar* _tmp1_;
			_tmp0_ = dino_gettext ("Owner");
			_tmp1_ = g_strdup (_tmp0_);
			_g_free0 (aff_str);
			aff_str = _tmp1_;
			break;
		}
		case XMPP_XEP_MUC_AFFILIATION_ADMIN:
		{
			const gchar* _tmp2_;
			gchar* _tmp3_;
			_tmp2_ = dino_gettext ("Admin");
			_tmp3_ = g_strdup (_tmp2_);
			_g_free0 (aff_str);
			aff_str = _tmp3_;
			break;
		}
		case XMPP_XEP_MUC_AFFILIATION_MEMBER:
		{
			const gchar* _tmp4_;
			gchar* _tmp5_;
			_tmp4_ = dino_gettext ("Member");
			_tmp5_ = g_strdup (_tmp4_);
			_g_free0 (aff_str);
			aff_str = _tmp5_;
			break;
		}
		default:
		{
			const gchar* _tmp6_;
			gchar* _tmp7_;
			_tmp6_ = dino_gettext ("User");
			_tmp7_ = g_strdup (_tmp6_);
			_g_free0 (aff_str);
			aff_str = _tmp7_;
			break;
		}
	}
	count = 0;
	{
		GeeIterator* _row_it = NULL;
		GeeHashMap* _tmp8_;
		GeeCollection* _tmp9_;
		GeeCollection* _tmp10_;
		GeeCollection* _tmp11_;
		GeeIterator* _tmp12_;
		GeeIterator* _tmp13_;
		_tmp8_ = self->row_wrappers;
		_tmp9_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = _tmp10_;
		_tmp12_ = gee_iterable_iterator ((GeeIterable*) _tmp11_);
		_tmp13_ = _tmp12_;
		_g_object_unref0 (_tmp11_);
		_row_it = _tmp13_;
		while (TRUE) {
			GeeIterator* _tmp14_;
			DinoUiOccupantMenuListRow* row = NULL;
			GeeIterator* _tmp15_;
			gpointer _tmp16_;
			XmppXepMucAffiliation aff = 0;
			DinoStreamInteractor* _tmp17_;
			DinoModuleIdentity* _tmp18_;
			gpointer _tmp19_;
			DinoMucManager* _tmp20_;
			DinoEntitiesConversation* _tmp21_;
			XmppJid* _tmp22_;
			XmppJid* _tmp23_;
			DinoUiOccupantMenuListRow* _tmp24_;
			XmppJid* _tmp25_;
			DinoEntitiesConversation* _tmp26_;
			DinoEntitiesAccount* _tmp27_;
			DinoEntitiesAccount* _tmp28_;
			XmppXepMucAffiliation* _tmp29_;
			XmppXepMucAffiliation* _tmp30_;
			XmppXepMucAffiliation _tmp31_;
			_tmp14_ = _row_it;
			if (!gee_iterator_next (_tmp14_)) {
				break;
			}
			_tmp15_ = _row_it;
			_tmp16_ = gee_iterator_get (_tmp15_);
			row = (DinoUiOccupantMenuListRow*) _tmp16_;
			_tmp17_ = self->priv->stream_interactor;
			_tmp18_ = dino_muc_manager_IDENTITY;
			_tmp19_ = dino_stream_interactor_get_module (_tmp17_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp18_);
			_tmp20_ = (DinoMucManager*) _tmp19_;
			_tmp21_ = self->priv->conversation;
			_tmp22_ = dino_entities_conversation_get_counterpart (_tmp21_);
			_tmp23_ = _tmp22_;
			_tmp24_ = row;
			_tmp25_ = _tmp24_->jid;
			_tmp26_ = self->priv->conversation;
			_tmp27_ = dino_entities_conversation_get_account (_tmp26_);
			_tmp28_ = _tmp27_;
			_tmp29_ = dino_muc_manager_get_affiliation (_tmp20_, _tmp23_, _tmp25_, _tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = *_tmp30_;
			_g_free0 (_tmp30_);
			_g_object_unref0 (_tmp20_);
			aff = _tmp31_;
			if (aff == affiliation) {
				gint _tmp32_;
				_tmp32_ = count;
				count = _tmp32_ + 1;
			}
			_g_object_unref0 (row);
		}
		_g_object_unref0 (_row_it);
	}
	_tmp33_ = (GtkLabel*) gtk_label_new ("");
	gtk_widget_set_margin_start ((GtkWidget*) _tmp33_, 10);
	gtk_label_set_xalign (_tmp33_, (gfloat) 0);
	g_object_ref_sink (_tmp33_);
	title_label = _tmp33_;
	_tmp34_ = title_label;
	_tmp35_ = aff_str;
	_tmp36_ = g_markup_escape_text (_tmp35_, (gssize) -1);
	_tmp37_ = _tmp36_;
	_tmp38_ = string_to_string (_tmp37_);
	_tmp39_ = g_strconcat ("<b>", _tmp38_, "</b>", NULL);
	_tmp40_ = _tmp39_;
	gtk_label_set_markup (_tmp34_, _tmp40_);
	_g_free0 (_tmp40_);
	_g_free0 (_tmp37_);
	_tmp41_ = g_strdup_printf ("%i", count);
	_tmp42_ = _tmp41_;
	_tmp43_ = (GtkLabel*) gtk_label_new (_tmp42_);
	gtk_label_set_xalign (_tmp43_, (gfloat) 0);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp43_, 7);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp43_, TRUE);
	g_object_ref_sink (_tmp43_);
	_tmp44_ = _tmp43_;
	_g_free0 (_tmp42_);
	count_label = _tmp44_;
	_tmp45_ = count_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp45_, "dim-label");
	if (top) {
		_tmp46_ = 5;
	} else {
		_tmp46_ = 15;
	}
	_tmp47_ = (GtkGrid*) gtk_grid_new ();
	gtk_widget_set_margin_top ((GtkWidget*) _tmp47_, _tmp46_);
	gtk_grid_set_column_spacing (_tmp47_, 5);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp47_, TRUE);
	g_object_ref_sink (_tmp47_);
	grid = _tmp47_;
	_tmp48_ = title_label;
	gtk_grid_attach (grid, (GtkWidget*) _tmp48_, 0, 0, 1, 1);
	_tmp49_ = count_label;
	gtk_grid_attach (grid, (GtkWidget*) _tmp49_, 1, 0, 1, 1);
	_tmp50_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp50_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp50_, TRUE);
	g_object_ref_sink (_tmp50_);
	_tmp51_ = _tmp50_;
	gtk_grid_attach (grid, (GtkWidget*) _tmp51_, 0, 1, 2, 1);
	_g_object_unref0 (_tmp51_);
	result = (GtkWidget*) grid;
	_g_object_unref0 (count_label);
	_g_object_unref0 (title_label);
	_g_free0 (aff_str);
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
dino_ui_occupant_menu_list_filter (DinoUiOccupantMenuList* self,
                                   GtkListBoxRow* r)
{
	DinoUiOccupantMenuListRow* row_wrapper = NULL;
	GeeHashMap* _tmp0_;
	GtkWidget* _tmp1_;
	gpointer _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (r != NULL, FALSE);
	_tmp0_ = self->row_wrappers;
	_tmp1_ = gtk_list_box_row_get_child (r);
	_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_);
	row_wrapper = (DinoUiOccupantMenuListRow*) _tmp2_;
	_tmp3_ = self->priv->filter_values;
	_tmp3__length1 = self->priv->filter_values_length1;
	{
		gchar** filter_collection = NULL;
		gint filter_collection_length1 = 0;
		gint _filter_collection_size_ = 0;
		gint filter_it = 0;
		filter_collection = _tmp3_;
		filter_collection_length1 = _tmp3__length1;
		for (filter_it = 0; filter_it < filter_collection_length1; filter_it = filter_it + 1) {
			gchar* _tmp4_;
			gchar* filter = NULL;
			_tmp4_ = g_strdup (filter_collection[filter_it]);
			filter = _tmp4_;
			{
				DinoUiOccupantMenuListRow* _tmp5_;
				GtkLabel* _tmp6_;
				const gchar* _tmp7_;
				const gchar* _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				const gchar* _tmp11_;
				gchar* _tmp12_;
				gchar* _tmp13_;
				gboolean _tmp14_;
				_tmp5_ = row_wrapper;
				_tmp6_ = _tmp5_->name_label;
				_tmp7_ = gtk_label_get_label (_tmp6_);
				_tmp8_ = _tmp7_;
				_tmp9_ = g_utf8_strdown (_tmp8_, (gssize) -1);
				_tmp10_ = _tmp9_;
				_tmp11_ = filter;
				_tmp12_ = g_utf8_strdown (_tmp11_, (gssize) -1);
				_tmp13_ = _tmp12_;
				_tmp14_ = string_contains (_tmp10_, _tmp13_);
				_g_free0 (_tmp13_);
				_g_free0 (_tmp10_);
				result = _tmp14_;
				_g_free0 (filter);
				_g_object_unref0 (row_wrapper);
				return result;
			}
		}
	}
	result = TRUE;
	_g_object_unref0 (row_wrapper);
	return result;
}

static XmppXepMucAffiliation*
_xmpp_xep_muc_affiliation_dup (XmppXepMucAffiliation* self)
{
	XmppXepMucAffiliation* dup;
	dup = g_new0 (XmppXepMucAffiliation, 1);
	memcpy (dup, self, sizeof (XmppXepMucAffiliation));
	return dup;
}

static gpointer
__xmpp_xep_muc_affiliation_dup0 (gpointer self)
{
	return self ? _xmpp_xep_muc_affiliation_dup (self) : NULL;
}

static gint
dino_ui_occupant_menu_list_sort (DinoUiOccupantMenuList* self,
                                 GtkListBoxRow* row1,
                                 GtkListBoxRow* row2)
{
	DinoUiOccupantMenuListRow* row_wrapper1 = NULL;
	GeeHashMap* _tmp0_;
	GtkWidget* _tmp1_;
	gpointer _tmp2_;
	DinoUiOccupantMenuListRow* row_wrapper2 = NULL;
	GeeHashMap* _tmp3_;
	GtkWidget* _tmp4_;
	gpointer _tmp5_;
	XmppXepMucAffiliation* _tmp6_ = NULL;
	DinoStreamInteractor* _tmp7_;
	DinoModuleIdentity* _tmp8_;
	gpointer _tmp9_;
	DinoMucManager* _tmp10_;
	DinoEntitiesConversation* _tmp11_;
	XmppJid* _tmp12_;
	XmppJid* _tmp13_;
	DinoUiOccupantMenuListRow* _tmp14_;
	XmppJid* _tmp15_;
	DinoUiOccupantMenuListRow* _tmp16_;
	DinoEntitiesConversation* _tmp17_;
	DinoEntitiesAccount* _tmp18_;
	DinoEntitiesAccount* _tmp19_;
	XmppXepMucAffiliation* _tmp20_;
	XmppXepMucAffiliation* _tmp21_;
	gint affiliation1 = 0;
	XmppXepMucAffiliation* _tmp24_ = NULL;
	DinoStreamInteractor* _tmp25_;
	DinoModuleIdentity* _tmp26_;
	gpointer _tmp27_;
	DinoMucManager* _tmp28_;
	DinoEntitiesConversation* _tmp29_;
	XmppJid* _tmp30_;
	XmppJid* _tmp31_;
	DinoUiOccupantMenuListRow* _tmp32_;
	XmppJid* _tmp33_;
	DinoUiOccupantMenuListRow* _tmp34_;
	DinoEntitiesConversation* _tmp35_;
	DinoEntitiesAccount* _tmp36_;
	DinoEntitiesAccount* _tmp37_;
	XmppXepMucAffiliation* _tmp38_;
	XmppXepMucAffiliation* _tmp39_;
	gint affiliation2 = 0;
	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_ = self->row_wrappers;
	_tmp1_ = gtk_list_box_row_get_child (row1);
	_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_);
	row_wrapper1 = (DinoUiOccupantMenuListRow*) _tmp2_;
	_tmp3_ = self->row_wrappers;
	_tmp4_ = gtk_list_box_row_get_child (row2);
	_tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp4_);
	row_wrapper2 = (DinoUiOccupantMenuListRow*) _tmp5_;
	_tmp7_ = self->priv->stream_interactor;
	_tmp8_ = dino_muc_manager_IDENTITY;
	_tmp9_ = dino_stream_interactor_get_module (_tmp7_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp8_);
	_tmp10_ = (DinoMucManager*) _tmp9_;
	_tmp11_ = self->priv->conversation;
	_tmp12_ = dino_entities_conversation_get_counterpart (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = row_wrapper1;
	_tmp15_ = _tmp14_->jid;
	_tmp16_ = row_wrapper1;
	_tmp17_ = _tmp16_->conversation;
	_tmp18_ = dino_entities_conversation_get_account (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = dino_muc_manager_get_affiliation (_tmp10_, _tmp13_, _tmp15_, _tmp19_);
	_tmp21_ = _tmp20_;
	_g_object_unref0 (_tmp10_);
	_tmp6_ = _tmp21_;
	if (_tmp6_ == NULL) {
		XmppXepMucAffiliation _tmp22_;
		XmppXepMucAffiliation* _tmp23_;
		_tmp22_ = XMPP_XEP_MUC_AFFILIATION_NONE;
		_tmp23_ = __xmpp_xep_muc_affiliation_dup0 (&_tmp22_);
		_g_free0 (_tmp6_);
		_tmp6_ = _tmp23_;
	}
	affiliation1 = dino_ui_occupant_menu_list_get_affiliation_ranking (self, *_tmp6_);
	_tmp25_ = self->priv->stream_interactor;
	_tmp26_ = dino_muc_manager_IDENTITY;
	_tmp27_ = dino_stream_interactor_get_module (_tmp25_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp26_);
	_tmp28_ = (DinoMucManager*) _tmp27_;
	_tmp29_ = self->priv->conversation;
	_tmp30_ = dino_entities_conversation_get_counterpart (_tmp29_);
	_tmp31_ = _tmp30_;
	_tmp32_ = row_wrapper2;
	_tmp33_ = _tmp32_->jid;
	_tmp34_ = row_wrapper2;
	_tmp35_ = _tmp34_->conversation;
	_tmp36_ = dino_entities_conversation_get_account (_tmp35_);
	_tmp37_ = _tmp36_;
	_tmp38_ = dino_muc_manager_get_affiliation (_tmp28_, _tmp31_, _tmp33_, _tmp37_);
	_tmp39_ = _tmp38_;
	_g_object_unref0 (_tmp28_);
	_tmp24_ = _tmp39_;
	if (_tmp24_ == NULL) {
		XmppXepMucAffiliation _tmp40_;
		XmppXepMucAffiliation* _tmp41_;
		_tmp40_ = XMPP_XEP_MUC_AFFILIATION_NONE;
		_tmp41_ = __xmpp_xep_muc_affiliation_dup0 (&_tmp40_);
		_g_free0 (_tmp24_);
		_tmp24_ = _tmp41_;
	}
	affiliation2 = dino_ui_occupant_menu_list_get_affiliation_ranking (self, *_tmp24_);
	if (affiliation1 < affiliation2) {
		result = -1;
		_g_free0 (_tmp24_);
		_g_free0 (_tmp6_);
		_g_object_unref0 (row_wrapper2);
		_g_object_unref0 (row_wrapper1);
		return result;
	} else {
		if (affiliation1 > affiliation2) {
			result = 1;
			_g_free0 (_tmp24_);
			_g_free0 (_tmp6_);
			_g_object_unref0 (row_wrapper2);
			_g_object_unref0 (row_wrapper1);
			return result;
		} else {
			DinoUiOccupantMenuListRow* _tmp42_;
			GtkLabel* _tmp43_;
			const gchar* _tmp44_;
			const gchar* _tmp45_;
			DinoUiOccupantMenuListRow* _tmp46_;
			GtkLabel* _tmp47_;
			const gchar* _tmp48_;
			const gchar* _tmp49_;
			_tmp42_ = row_wrapper1;
			_tmp43_ = _tmp42_->name_label;
			_tmp44_ = gtk_label_get_label (_tmp43_);
			_tmp45_ = _tmp44_;
			_tmp46_ = row_wrapper2;
			_tmp47_ = _tmp46_->name_label;
			_tmp48_ = gtk_label_get_label (_tmp47_);
			_tmp49_ = _tmp48_;
			result = g_utf8_collate (_tmp45_, _tmp49_);
			_g_free0 (_tmp24_);
			_g_free0 (_tmp6_);
			_g_object_unref0 (row_wrapper2);
			_g_object_unref0 (row_wrapper1);
			return result;
		}
	}
}

static gint
dino_ui_occupant_menu_list_get_affiliation_ranking (DinoUiOccupantMenuList* self,
                                                    XmppXepMucAffiliation affiliation)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	switch (affiliation) {
		case XMPP_XEP_MUC_AFFILIATION_OWNER:
		{
			result = 1;
			return result;
		}
		case XMPP_XEP_MUC_AFFILIATION_ADMIN:
		{
			result = 2;
			return result;
		}
		case XMPP_XEP_MUC_AFFILIATION_MEMBER:
		{
			result = 3;
			return result;
		}
		default:
		{
			result = 4;
			return result;
		}
	}
}

static void
dino_ui_occupant_menu_list_class_init (DinoUiOccupantMenuListClass * klass,
                                       gpointer klass_data)
{
	dino_ui_occupant_menu_list_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiOccupantMenuList_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dino_ui_occupant_menu_list_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/im/dino/Dino/occupant_list.ui");
	dino_ui_occupant_menu_list_signals[DINO_UI_OCCUPANT_MENU_LIST_CONVERSATION_SELECTED_SIGNAL] = g_signal_new ("conversation-selected", DINO_UI_OCCUPANT_MENU_TYPE_LIST, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DINO_ENTITIES_TYPE_CONVERSATION);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "list_box", FALSE, G_STRUCT_OFFSET (DinoUiOccupantMenuList, list_box));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "search_entry", FALSE, DinoUiOccupantMenuList_private_offset + G_STRUCT_OFFSET (DinoUiOccupantMenuListPrivate, search_entry));
}

static void
dino_ui_occupant_menu_list_instance_init (DinoUiOccupantMenuList * self,
                                          gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	self->priv = dino_ui_occupant_menu_list_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, gtk_widget_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _xmpp_jid_hash_func_gee_hash_data_func, NULL, NULL, _xmpp_jid_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->rows = _tmp0_;
	_tmp1_ = gee_hash_map_new (gtk_widget_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, DINO_UI_OCCUPANT_MENU_TYPE_LIST_ROW, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->row_wrappers = _tmp1_;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
dino_ui_occupant_menu_list_finalize (GObject * obj)
{
	DinoUiOccupantMenuList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_OCCUPANT_MENU_TYPE_LIST, DinoUiOccupantMenuList);
	_g_object_unref0 (self->priv->stream_interactor);
	_g_object_unref0 (self->priv->conversation);
	self->priv->filter_values = (_vala_array_free (self->priv->filter_values, self->priv->filter_values_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (self->priv->rows);
	_g_object_unref0 (self->row_wrappers);
	G_OBJECT_CLASS (dino_ui_occupant_menu_list_parent_class)->finalize (obj);
}

static GType
dino_ui_occupant_menu_list_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiOccupantMenuListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_occupant_menu_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiOccupantMenuList), 0, (GInstanceInitFunc) dino_ui_occupant_menu_list_instance_init, NULL };
	GType dino_ui_occupant_menu_list_type_id;
	dino_ui_occupant_menu_list_type_id = g_type_register_static (gtk_box_get_type (), "DinoUiOccupantMenuList", &g_define_type_info, 0);
	DinoUiOccupantMenuList_private_offset = g_type_add_instance_private (dino_ui_occupant_menu_list_type_id, sizeof (DinoUiOccupantMenuListPrivate));
	return dino_ui_occupant_menu_list_type_id;
}

GType
dino_ui_occupant_menu_list_get_type (void)
{
	static volatile gsize dino_ui_occupant_menu_list_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_occupant_menu_list_type_id__once)) {
		GType dino_ui_occupant_menu_list_type_id;
		dino_ui_occupant_menu_list_type_id = dino_ui_occupant_menu_list_get_type_once ();
		g_once_init_leave (&dino_ui_occupant_menu_list_type_id__once, dino_ui_occupant_menu_list_type_id);
	}
	return dino_ui_occupant_menu_list_type_id__once;
}

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

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

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

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

