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

#include <glib-object.h>
#include "libdino.h"
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "xmpp-vala.h"
#include <gtk/gtk.h>
#include "dino_i18n.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_CONVERSATION_SUMMARY_TYPE_REACTIONS_CONTROLLER (dino_ui_conversation_summary_reactions_controller_get_type ())
#define DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_CONTROLLER, DinoUiConversationSummaryReactionsController))
#define DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_CONTROLLER, DinoUiConversationSummaryReactionsControllerClass))
#define DINO_UI_CONVERSATION_SUMMARY_IS_REACTIONS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_CONTROLLER))
#define DINO_UI_CONVERSATION_SUMMARY_IS_REACTIONS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_CONTROLLER))
#define DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_CONTROLLER, DinoUiConversationSummaryReactionsControllerClass))

typedef struct _DinoUiConversationSummaryReactionsController DinoUiConversationSummaryReactionsController;
typedef struct _DinoUiConversationSummaryReactionsControllerClass DinoUiConversationSummaryReactionsControllerClass;
typedef struct _DinoUiConversationSummaryReactionsControllerPrivate DinoUiConversationSummaryReactionsControllerPrivate;

#define DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET (dino_ui_conversation_summary_reactions_widget_get_type ())
#define DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET, DinoUiConversationSummaryReactionsWidget))
#define DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET, DinoUiConversationSummaryReactionsWidgetClass))
#define DINO_UI_CONVERSATION_SUMMARY_IS_REACTIONS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET))
#define DINO_UI_CONVERSATION_SUMMARY_IS_REACTIONS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET))
#define DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET, DinoUiConversationSummaryReactionsWidgetClass))

typedef struct _DinoUiConversationSummaryReactionsWidget DinoUiConversationSummaryReactionsWidget;
typedef struct _DinoUiConversationSummaryReactionsWidgetClass DinoUiConversationSummaryReactionsWidgetClass;
enum  {
	DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_0_PROPERTY,
	DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_NUM_PROPERTIES
};
static GParamSpec* dino_ui_conversation_summary_reactions_controller_properties[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_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 _dino_reaction_users_unref0(var) ((var == NULL) ? NULL : (var = (dino_reaction_users_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_BOX_ACTIVATED_SIGNAL,
	DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_NUM_SIGNALS
};
static guint dino_ui_conversation_summary_reactions_controller_signals[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_NUM_SIGNALS] = {0};
typedef struct _DinoUiConversationSummaryReactionsWidgetPrivate DinoUiConversationSummaryReactionsWidgetPrivate;
enum  {
	DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_0_PROPERTY,
	DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_NUM_PROPERTIES
};
static GParamSpec* dino_ui_conversation_summary_reactions_widget_properties[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_NUM_PROPERTIES];
typedef struct _Block40Data Block40Data;
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
enum  {
	DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_EMOJI_PICKED_SIGNAL,
	DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_EMOJI_CLICKED_SIGNAL,
	DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_NUM_SIGNALS
};
static guint dino_ui_conversation_summary_reactions_widget_signals[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_NUM_SIGNALS] = {0};

struct _DinoUiConversationSummaryReactionsController {
	GObject parent_instance;
	DinoUiConversationSummaryReactionsControllerPrivate * priv;
};

struct _DinoUiConversationSummaryReactionsControllerClass {
	GObjectClass parent_class;
};

struct _DinoUiConversationSummaryReactionsControllerPrivate {
	DinoEntitiesConversation* conversation;
	DinoEntitiesAccount* account;
	DinoContentItem* content_item;
	DinoStreamInteractor* stream_interactor;
	GeeHashMap* reactions;
	DinoUiConversationSummaryReactionsWidget* widget;
};

struct _DinoUiConversationSummaryReactionsWidget {
	GtkGrid parent_instance;
	DinoUiConversationSummaryReactionsWidgetPrivate * priv;
};

struct _DinoUiConversationSummaryReactionsWidgetClass {
	GtkGridClass parent_class;
};

struct _DinoUiConversationSummaryReactionsWidgetPrivate {
	GeeHashMap* reaction_counts;
	GeeHashMap* reaction_buttons;
	GtkMenuButton* add_button;
};

struct _Block40Data {
	int _ref_count_;
	DinoUiConversationSummaryReactionsWidget* self;
	gchar* reaction;
};

static gint DinoUiConversationSummaryReactionsController_private_offset;
static gpointer dino_ui_conversation_summary_reactions_controller_parent_class = NULL;
static gint DinoUiConversationSummaryReactionsWidget_private_offset;
static gpointer dino_ui_conversation_summary_reactions_widget_parent_class = NULL;

VALA_EXTERN GType dino_ui_conversation_summary_reactions_controller_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiConversationSummaryReactionsController, g_object_unref)
VALA_EXTERN GType dino_ui_conversation_summary_reactions_widget_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiConversationSummaryReactionsWidget, g_object_unref)
VALA_EXTERN DinoUiConversationSummaryReactionsController* dino_ui_conversation_summary_reactions_controller_new (DinoEntitiesConversation* conversation,
                                                                                                     DinoContentItem* content_item,
                                                                                                     DinoStreamInteractor* stream_interactor);
VALA_EXTERN DinoUiConversationSummaryReactionsController* dino_ui_conversation_summary_reactions_controller_construct (GType object_type,
                                                                                                           DinoEntitiesConversation* conversation,
                                                                                                           DinoContentItem* content_item,
                                                                                                           DinoStreamInteractor* stream_interactor);
VALA_EXTERN void dino_ui_conversation_summary_reactions_controller_init (DinoUiConversationSummaryReactionsController* self);
VALA_EXTERN void dino_ui_conversation_summary_reactions_controller_reaction_added (DinoUiConversationSummaryReactionsController* self,
                                                                       const gchar* reaction,
                                                                       XmppJid* jid);
static void __lambda15_ (DinoUiConversationSummaryReactionsController* self,
                  DinoEntitiesAccount* account,
                  gint content_item_id,
                  XmppJid* jid,
                  const gchar* reaction);
static void ___lambda15__dino_reactions_reaction_added (DinoReactions* _sender,
                                                 DinoEntitiesAccount* account,
                                                 gint content_item_id,
                                                 XmppJid* jid,
                                                 const gchar* reaction,
                                                 gpointer self);
static void __lambda16_ (DinoUiConversationSummaryReactionsController* self,
                  DinoEntitiesAccount* account,
                  gint content_item_id,
                  XmppJid* jid,
                  const gchar* reaction);
VALA_EXTERN void dino_ui_conversation_summary_reactions_controller_reaction_removed (DinoUiConversationSummaryReactionsController* self,
                                                                         const gchar* reaction,
                                                                         XmppJid* jid);
static void ___lambda16__dino_reactions_reaction_removed (DinoReactions* _sender,
                                                   DinoEntitiesAccount* account,
                                                   gint content_item_id,
                                                   XmppJid* jid,
                                                   const gchar* reaction,
                                                   gpointer self);
static void dino_ui_conversation_summary_reactions_controller_initialize_widget (DinoUiConversationSummaryReactionsController* self);
VALA_EXTERN DinoUiConversationSummaryReactionsWidget* dino_ui_conversation_summary_reactions_widget_new (void);
VALA_EXTERN DinoUiConversationSummaryReactionsWidget* dino_ui_conversation_summary_reactions_widget_construct (GType object_type);
static void __lambda13_ (DinoUiConversationSummaryReactionsController* self,
                  const gchar* emoji);
static void ___lambda13__dino_ui_conversation_summary_reactions_widget_emoji_picked (DinoUiConversationSummaryReactionsWidget* _sender,
                                                                              const gchar* emoji,
                                                                              gpointer self);
static void __lambda14_ (DinoUiConversationSummaryReactionsController* self,
                  const gchar* emoji);
static void ___lambda14__dino_ui_conversation_summary_reactions_widget_emoji_clicked (DinoUiConversationSummaryReactionsWidget* _sender,
                                                                               const gchar* emoji,
                                                                               gpointer self);
static gboolean _xmpp_jid_equals_func_gee_equal_data_func (gconstpointer a,
                                                    gconstpointer b,
                                                    gpointer self);
VALA_EXTERN void dino_ui_conversation_summary_reactions_widget_update_reaction (DinoUiConversationSummaryReactionsWidget* self,
                                                                    const gchar* reaction,
                                                                    gint count,
                                                                    gboolean own,
                                                                    GeeList* names);
static GeeList* dino_ui_conversation_summary_reactions_controller_update_tooltip (DinoUiConversationSummaryReactionsController* self,
                                                                           const gchar* reaction);
VALA_EXTERN void dino_ui_conversation_summary_reactions_widget_remove_reaction (DinoUiConversationSummaryReactionsWidget* self,
                                                                    const gchar* reaction);
VALA_EXTERN gchar* dino_ui_util_get_participant_display_name (DinoStreamInteractor* stream_interactor,
                                                  DinoEntitiesConversation* conversation,
                                                  XmppJid* participant,
                                                  gboolean me_is_me);
static void dino_ui_conversation_summary_reactions_controller_finalize (GObject * obj);
static GType dino_ui_conversation_summary_reactions_controller_get_type_once (void);
VALA_EXTERN void dino_ui_util_menu_button_set_icon_with_size (GtkMenuButton* menu_button,
                                                  const gchar* icon_name,
                                                  gint pixel_size);
static void __lambda11_ (DinoUiConversationSummaryReactionsWidget* self,
                  const gchar* emoji);
static void ___lambda11__gtk_emoji_chooser_emoji_picked (GtkEmojiChooser* _sender,
                                                  const gchar* text,
                                                  gpointer self);
static Block40Data* block40_data_ref (Block40Data* _data40_);
static void block40_data_unref (void * _userdata_);
static void ___lambda12_ (Block40Data* _data40_);
static void ____lambda12__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dino_ui_conversation_summary_reactions_widget_finalize (GObject * obj);
static GType dino_ui_conversation_summary_reactions_widget_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_ui_conversation_summary_reactions_controller_get_instance_private (DinoUiConversationSummaryReactionsController* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiConversationSummaryReactionsController_private_offset);
}

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

DinoUiConversationSummaryReactionsController*
dino_ui_conversation_summary_reactions_controller_construct (GType object_type,
                                                             DinoEntitiesConversation* conversation,
                                                             DinoContentItem* content_item,
                                                             DinoStreamInteractor* stream_interactor)
{
	DinoUiConversationSummaryReactionsController * self = NULL;
	DinoEntitiesConversation* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	DinoEntitiesAccount* _tmp2_;
	DinoEntitiesAccount* _tmp3_;
	DinoContentItem* _tmp4_;
	DinoStreamInteractor* _tmp5_;
	g_return_val_if_fail (conversation != NULL, NULL);
	g_return_val_if_fail (content_item != NULL, NULL);
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	self = (DinoUiConversationSummaryReactionsController*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (conversation);
	_g_object_unref0 (self->priv->conversation);
	self->priv->conversation = _tmp0_;
	_tmp1_ = dino_entities_conversation_get_account (conversation);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (self->priv->account);
	self->priv->account = _tmp3_;
	_tmp4_ = _g_object_ref0 (content_item);
	_g_object_unref0 (self->priv->content_item);
	self->priv->content_item = _tmp4_;
	_tmp5_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp5_;
	return self;
}

DinoUiConversationSummaryReactionsController*
dino_ui_conversation_summary_reactions_controller_new (DinoEntitiesConversation* conversation,
                                                       DinoContentItem* content_item,
                                                       DinoStreamInteractor* stream_interactor)
{
	return dino_ui_conversation_summary_reactions_controller_construct (DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_CONTROLLER, conversation, content_item, stream_interactor);
}

static void
__lambda15_ (DinoUiConversationSummaryReactionsController* self,
             DinoEntitiesAccount* account,
             gint content_item_id,
             XmppJid* jid,
             const gchar* reaction)
{
	DinoContentItem* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (reaction != NULL);
	_tmp0_ = self->priv->content_item;
	_tmp1_ = dino_content_item_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == content_item_id) {
		dino_ui_conversation_summary_reactions_controller_reaction_added (self, reaction, jid);
	}
}

static void
___lambda15__dino_reactions_reaction_added (DinoReactions* _sender,
                                            DinoEntitiesAccount* account,
                                            gint content_item_id,
                                            XmppJid* jid,
                                            const gchar* reaction,
                                            gpointer self)
{
	__lambda15_ ((DinoUiConversationSummaryReactionsController*) self, account, content_item_id, jid, reaction);
}

static void
__lambda16_ (DinoUiConversationSummaryReactionsController* self,
             DinoEntitiesAccount* account,
             gint content_item_id,
             XmppJid* jid,
             const gchar* reaction)
{
	DinoContentItem* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (reaction != NULL);
	_tmp0_ = self->priv->content_item;
	_tmp1_ = dino_content_item_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == content_item_id) {
		dino_ui_conversation_summary_reactions_controller_reaction_removed (self, reaction, jid);
	}
}

static void
___lambda16__dino_reactions_reaction_removed (DinoReactions* _sender,
                                              DinoEntitiesAccount* account,
                                              gint content_item_id,
                                              XmppJid* jid,
                                              const gchar* reaction,
                                              gpointer self)
{
	__lambda16_ ((DinoUiConversationSummaryReactionsController*) self, account, content_item_id, jid, reaction);
}

void
dino_ui_conversation_summary_reactions_controller_init (DinoUiConversationSummaryReactionsController* self)
{
	GeeList* reactions = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoReactions* _tmp3_;
	DinoEntitiesConversation* _tmp4_;
	DinoContentItem* _tmp5_;
	GeeList* _tmp6_;
	GeeList* _tmp7_;
	DinoStreamInteractor* _tmp30_;
	DinoModuleIdentity* _tmp31_;
	gpointer _tmp32_;
	DinoReactions* _tmp33_;
	DinoStreamInteractor* _tmp34_;
	DinoModuleIdentity* _tmp35_;
	gpointer _tmp36_;
	DinoReactions* _tmp37_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_reactions_IDENTITY;
	_tmp2_ = dino_stream_interactor_get_module (_tmp0_, DINO_TYPE_REACTIONS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (DinoReactions*) _tmp2_;
	_tmp4_ = self->priv->conversation;
	_tmp5_ = self->priv->content_item;
	_tmp6_ = dino_reactions_get_item_reactions (_tmp3_, _tmp4_, _tmp5_);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (_tmp3_);
	reactions = _tmp7_;
	{
		GeeList* _reaction_users_list = NULL;
		GeeList* _tmp8_;
		gint _reaction_users_size = 0;
		GeeList* _tmp9_;
		gint _tmp10_;
		gint _tmp11_;
		gint _reaction_users_index = 0;
		_tmp8_ = reactions;
		_reaction_users_list = _tmp8_;
		_tmp9_ = _reaction_users_list;
		_tmp10_ = gee_collection_get_size ((GeeCollection*) _tmp9_);
		_tmp11_ = _tmp10_;
		_reaction_users_size = _tmp11_;
		_reaction_users_index = -1;
		while (TRUE) {
			gint _tmp12_;
			gint _tmp13_;
			DinoReactionUsers* reaction_users = NULL;
			GeeList* _tmp14_;
			gpointer _tmp15_;
			_reaction_users_index = _reaction_users_index + 1;
			_tmp12_ = _reaction_users_index;
			_tmp13_ = _reaction_users_size;
			if (!(_tmp12_ < _tmp13_)) {
				break;
			}
			_tmp14_ = _reaction_users_list;
			_tmp15_ = gee_list_get (_tmp14_, _reaction_users_index);
			reaction_users = (DinoReactionUsers*) _tmp15_;
			{
				GeeList* _jid_list = NULL;
				DinoReactionUsers* _tmp16_;
				GeeList* _tmp17_;
				GeeList* _tmp18_;
				gint _jid_size = 0;
				GeeList* _tmp19_;
				gint _tmp20_;
				gint _tmp21_;
				gint _jid_index = 0;
				_tmp16_ = reaction_users;
				_tmp17_ = dino_reaction_users_get_jids (_tmp16_);
				_tmp18_ = _tmp17_;
				_jid_list = _tmp18_;
				_tmp19_ = _jid_list;
				_tmp20_ = gee_collection_get_size ((GeeCollection*) _tmp19_);
				_tmp21_ = _tmp20_;
				_jid_size = _tmp21_;
				_jid_index = -1;
				while (TRUE) {
					gint _tmp22_;
					gint _tmp23_;
					XmppJid* jid = NULL;
					GeeList* _tmp24_;
					gpointer _tmp25_;
					DinoReactionUsers* _tmp26_;
					const gchar* _tmp27_;
					const gchar* _tmp28_;
					XmppJid* _tmp29_;
					_jid_index = _jid_index + 1;
					_tmp22_ = _jid_index;
					_tmp23_ = _jid_size;
					if (!(_tmp22_ < _tmp23_)) {
						break;
					}
					_tmp24_ = _jid_list;
					_tmp25_ = gee_list_get (_tmp24_, _jid_index);
					jid = (XmppJid*) _tmp25_;
					_tmp26_ = reaction_users;
					_tmp27_ = dino_reaction_users_get_reaction (_tmp26_);
					_tmp28_ = _tmp27_;
					_tmp29_ = jid;
					dino_ui_conversation_summary_reactions_controller_reaction_added (self, _tmp28_, _tmp29_);
					_xmpp_jid_unref0 (jid);
				}
			}
			_dino_reaction_users_unref0 (reaction_users);
		}
	}
	_tmp30_ = self->priv->stream_interactor;
	_tmp31_ = dino_reactions_IDENTITY;
	_tmp32_ = dino_stream_interactor_get_module (_tmp30_, DINO_TYPE_REACTIONS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp31_);
	_tmp33_ = (DinoReactions*) _tmp32_;
	g_signal_connect_object (_tmp33_, "reaction-added", (GCallback) ___lambda15__dino_reactions_reaction_added, self, 0);
	_g_object_unref0 (_tmp33_);
	_tmp34_ = self->priv->stream_interactor;
	_tmp35_ = dino_reactions_IDENTITY;
	_tmp36_ = dino_stream_interactor_get_module (_tmp34_, DINO_TYPE_REACTIONS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp35_);
	_tmp37_ = (DinoReactions*) _tmp36_;
	g_signal_connect_object (_tmp37_, "reaction-removed", (GCallback) ___lambda16__dino_reactions_reaction_removed, self, 0);
	_g_object_unref0 (_tmp37_);
	_g_object_unref0 (reactions);
}

static void
__lambda13_ (DinoUiConversationSummaryReactionsController* self,
             const gchar* emoji)
{
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoReactions* _tmp3_;
	DinoEntitiesConversation* _tmp4_;
	DinoContentItem* _tmp5_;
	g_return_if_fail (emoji != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_reactions_IDENTITY;
	_tmp2_ = dino_stream_interactor_get_module (_tmp0_, DINO_TYPE_REACTIONS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (DinoReactions*) _tmp2_;
	_tmp4_ = self->priv->conversation;
	_tmp5_ = self->priv->content_item;
	dino_reactions_add_reaction (_tmp3_, _tmp4_, _tmp5_, emoji);
	_g_object_unref0 (_tmp3_);
}

static void
___lambda13__dino_ui_conversation_summary_reactions_widget_emoji_picked (DinoUiConversationSummaryReactionsWidget* _sender,
                                                                         const gchar* emoji,
                                                                         gpointer self)
{
	__lambda13_ ((DinoUiConversationSummaryReactionsController*) self, emoji);
}

static void
__lambda14_ (DinoUiConversationSummaryReactionsController* self,
             const gchar* emoji)
{
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	GeeList* _tmp2_;
	DinoEntitiesAccount* _tmp3_;
	XmppJid* _tmp4_;
	XmppJid* _tmp5_;
	XmppJid* _tmp6_;
	gboolean _tmp7_;
	g_return_if_fail (emoji != NULL);
	_tmp0_ = self->priv->reactions;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, emoji);
	_tmp2_ = (GeeList*) _tmp1_;
	_tmp3_ = self->priv->account;
	_tmp4_ = dino_entities_account_get_bare_jid (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp7_ = gee_collection_contains ((GeeCollection*) _tmp2_, _tmp6_);
	_xmpp_jid_unref0 (_tmp6_);
	_g_object_unref0 (_tmp2_);
	if (_tmp7_) {
		DinoStreamInteractor* _tmp8_;
		DinoModuleIdentity* _tmp9_;
		gpointer _tmp10_;
		DinoReactions* _tmp11_;
		DinoEntitiesConversation* _tmp12_;
		DinoContentItem* _tmp13_;
		_tmp8_ = self->priv->stream_interactor;
		_tmp9_ = dino_reactions_IDENTITY;
		_tmp10_ = dino_stream_interactor_get_module (_tmp8_, DINO_TYPE_REACTIONS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp9_);
		_tmp11_ = (DinoReactions*) _tmp10_;
		_tmp12_ = self->priv->conversation;
		_tmp13_ = self->priv->content_item;
		dino_reactions_remove_reaction (_tmp11_, _tmp12_, _tmp13_, emoji);
		_g_object_unref0 (_tmp11_);
	} else {
		DinoStreamInteractor* _tmp14_;
		DinoModuleIdentity* _tmp15_;
		gpointer _tmp16_;
		DinoReactions* _tmp17_;
		DinoEntitiesConversation* _tmp18_;
		DinoContentItem* _tmp19_;
		_tmp14_ = self->priv->stream_interactor;
		_tmp15_ = dino_reactions_IDENTITY;
		_tmp16_ = dino_stream_interactor_get_module (_tmp14_, DINO_TYPE_REACTIONS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp15_);
		_tmp17_ = (DinoReactions*) _tmp16_;
		_tmp18_ = self->priv->conversation;
		_tmp19_ = self->priv->content_item;
		dino_reactions_add_reaction (_tmp17_, _tmp18_, _tmp19_, emoji);
		_g_object_unref0 (_tmp17_);
	}
}

static void
___lambda14__dino_ui_conversation_summary_reactions_widget_emoji_clicked (DinoUiConversationSummaryReactionsWidget* _sender,
                                                                          const gchar* emoji,
                                                                          gpointer self)
{
	__lambda14_ ((DinoUiConversationSummaryReactionsController*) self, emoji);
}

static void
dino_ui_conversation_summary_reactions_controller_initialize_widget (DinoUiConversationSummaryReactionsController* self)
{
	DinoUiConversationSummaryReactionsWidget* _tmp0_;
	DinoUiConversationSummaryReactionsWidget* _tmp1_;
	DinoUiConversationSummaryReactionsWidget* _tmp2_;
	DinoUiConversationSummaryReactionsWidget* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = dino_ui_conversation_summary_reactions_widget_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->widget);
	self->priv->widget = _tmp0_;
	_tmp1_ = self->priv->widget;
	g_signal_connect_object (_tmp1_, "emoji-picked", (GCallback) ___lambda13__dino_ui_conversation_summary_reactions_widget_emoji_picked, self, 0);
	_tmp2_ = self->priv->widget;
	g_signal_connect_object (_tmp2_, "emoji-clicked", (GCallback) ___lambda14__dino_ui_conversation_summary_reactions_widget_emoji_clicked, self, 0);
	_tmp3_ = self->priv->widget;
	g_signal_emit (self, dino_ui_conversation_summary_reactions_controller_signals[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_BOX_ACTIVATED_SIGNAL], 0, (GtkWidget*) _tmp3_);
}

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

void
dino_ui_conversation_summary_reactions_controller_reaction_added (DinoUiConversationSummaryReactionsController* self,
                                                                  const gchar* reaction,
                                                                  XmppJid* jid)
{
	DinoUiConversationSummaryReactionsWidget* _tmp0_;
	GeeHashMap* _tmp1_;
	gboolean _tmp5_ = FALSE;
	DinoEntitiesAccount* _tmp6_;
	XmppJid* _tmp7_;
	XmppJid* _tmp8_;
	XmppJid* _tmp9_;
	gboolean _tmp10_;
	GeeHashMap* _tmp14_;
	gpointer _tmp15_;
	GeeList* _tmp16_;
	GeeHashMap* _tmp17_;
	gpointer _tmp18_;
	GeeList* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	gboolean _tmp22_;
	DinoUiConversationSummaryReactionsWidget* _tmp23_;
	GeeHashMap* _tmp24_;
	gpointer _tmp25_;
	GeeList* _tmp26_;
	gint _tmp27_;
	gint _tmp28_;
	GeeHashMap* _tmp29_;
	gpointer _tmp30_;
	GeeList* _tmp31_;
	DinoEntitiesAccount* _tmp32_;
	XmppJid* _tmp33_;
	XmppJid* _tmp34_;
	XmppJid* _tmp35_;
	GeeList* _tmp36_;
	GeeList* _tmp37_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (reaction != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = self->priv->widget;
	if (_tmp0_ == NULL) {
		dino_ui_conversation_summary_reactions_controller_initialize_widget (self);
	}
	_tmp1_ = self->priv->reactions;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp1_, reaction)) {
		GeeHashMap* _tmp2_;
		GeeArrayList* _tmp3_;
		GeeArrayList* _tmp4_;
		_tmp2_ = self->priv->reactions;
		_tmp3_ = gee_array_list_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, _xmpp_jid_equals_func_gee_equal_data_func, NULL, NULL);
		_tmp4_ = _tmp3_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp2_, reaction, (GeeList*) _tmp4_);
		_g_object_unref0 (_tmp4_);
	}
	_tmp6_ = self->priv->account;
	_tmp7_ = dino_entities_account_get_bare_jid (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp10_ = xmpp_jid_equals_bare (jid, _tmp9_);
	_xmpp_jid_unref0 (_tmp9_);
	if (_tmp10_) {
		GeeHashMap* _tmp11_;
		gpointer _tmp12_;
		GeeList* _tmp13_;
		_tmp11_ = self->priv->reactions;
		_tmp12_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp11_, reaction);
		_tmp13_ = (GeeList*) _tmp12_;
		_tmp5_ = gee_collection_contains ((GeeCollection*) _tmp13_, jid);
		_g_object_unref0 (_tmp13_);
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		return;
	}
	_tmp14_ = self->priv->reactions;
	_tmp15_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp14_, reaction);
	_tmp16_ = (GeeList*) _tmp15_;
	gee_collection_add ((GeeCollection*) _tmp16_, jid);
	_g_object_unref0 (_tmp16_);
	_tmp17_ = self->priv->reactions;
	_tmp18_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp17_, reaction);
	_tmp19_ = (GeeList*) _tmp18_;
	_tmp20_ = gee_collection_get_size ((GeeCollection*) _tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = _tmp21_ == 0;
	_g_object_unref0 (_tmp19_);
	if (_tmp22_) {
		return;
	}
	_tmp23_ = self->priv->widget;
	_tmp24_ = self->priv->reactions;
	_tmp25_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp24_, reaction);
	_tmp26_ = (GeeList*) _tmp25_;
	_tmp27_ = gee_collection_get_size ((GeeCollection*) _tmp26_);
	_tmp28_ = _tmp27_;
	_tmp29_ = self->priv->reactions;
	_tmp30_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp29_, reaction);
	_tmp31_ = (GeeList*) _tmp30_;
	_tmp32_ = self->priv->account;
	_tmp33_ = dino_entities_account_get_bare_jid (_tmp32_);
	_tmp34_ = _tmp33_;
	_tmp35_ = _tmp34_;
	_tmp36_ = dino_ui_conversation_summary_reactions_controller_update_tooltip (self, reaction);
	_tmp37_ = _tmp36_;
	dino_ui_conversation_summary_reactions_widget_update_reaction (_tmp23_, reaction, _tmp28_, gee_collection_contains ((GeeCollection*) _tmp31_, _tmp35_), _tmp37_);
	_g_object_unref0 (_tmp37_);
	_xmpp_jid_unref0 (_tmp35_);
	_g_object_unref0 (_tmp31_);
	_g_object_unref0 (_tmp26_);
}

void
dino_ui_conversation_summary_reactions_controller_reaction_removed (DinoUiConversationSummaryReactionsController* self,
                                                                    const gchar* reaction,
                                                                    XmppJid* jid)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	gpointer _tmp2_;
	GeeList* _tmp3_;
	GeeHashMap* _tmp4_;
	gpointer _tmp5_;
	GeeList* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	gboolean _tmp9_;
	GeeHashMap* _tmp27_;
	gint _tmp28_;
	gint _tmp29_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (reaction != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = self->priv->reactions;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, reaction)) {
		return;
	}
	_tmp1_ = self->priv->reactions;
	_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, reaction);
	_tmp3_ = (GeeList*) _tmp2_;
	gee_collection_remove ((GeeCollection*) _tmp3_, jid);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->reactions;
	_tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp4_, reaction);
	_tmp6_ = (GeeList*) _tmp5_;
	_tmp7_ = gee_collection_get_size ((GeeCollection*) _tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp8_ > 0;
	_g_object_unref0 (_tmp6_);
	if (_tmp9_) {
		DinoUiConversationSummaryReactionsWidget* _tmp10_;
		GeeHashMap* _tmp11_;
		gpointer _tmp12_;
		GeeList* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		GeeHashMap* _tmp16_;
		gpointer _tmp17_;
		GeeList* _tmp18_;
		DinoEntitiesAccount* _tmp19_;
		XmppJid* _tmp20_;
		XmppJid* _tmp21_;
		XmppJid* _tmp22_;
		GeeList* _tmp23_;
		GeeList* _tmp24_;
		_tmp10_ = self->priv->widget;
		_tmp11_ = self->priv->reactions;
		_tmp12_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp11_, reaction);
		_tmp13_ = (GeeList*) _tmp12_;
		_tmp14_ = gee_collection_get_size ((GeeCollection*) _tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = self->priv->reactions;
		_tmp17_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp16_, reaction);
		_tmp18_ = (GeeList*) _tmp17_;
		_tmp19_ = self->priv->account;
		_tmp20_ = dino_entities_account_get_bare_jid (_tmp19_);
		_tmp21_ = _tmp20_;
		_tmp22_ = _tmp21_;
		_tmp23_ = dino_ui_conversation_summary_reactions_controller_update_tooltip (self, reaction);
		_tmp24_ = _tmp23_;
		dino_ui_conversation_summary_reactions_widget_update_reaction (_tmp10_, reaction, _tmp15_, gee_collection_contains ((GeeCollection*) _tmp18_, _tmp22_), _tmp24_);
		_g_object_unref0 (_tmp24_);
		_xmpp_jid_unref0 (_tmp22_);
		_g_object_unref0 (_tmp18_);
		_g_object_unref0 (_tmp13_);
	} else {
		DinoUiConversationSummaryReactionsWidget* _tmp25_;
		GeeHashMap* _tmp26_;
		_tmp25_ = self->priv->widget;
		dino_ui_conversation_summary_reactions_widget_remove_reaction (_tmp25_, reaction);
		_tmp26_ = self->priv->reactions;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp26_, reaction, NULL);
	}
	_tmp27_ = self->priv->reactions;
	_tmp28_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp27_);
	_tmp29_ = _tmp28_;
	if (_tmp29_ == 0) {
		DinoUiConversationSummaryReactionsWidget* _tmp30_;
		_tmp30_ = self->priv->widget;
		gtk_widget_unparent ((GtkWidget*) _tmp30_);
		_g_object_unref0 (self->priv->widget);
		self->priv->widget = NULL;
	}
}

static GeeList*
dino_ui_conversation_summary_reactions_controller_update_tooltip (DinoUiConversationSummaryReactionsController* self,
                                                                  const gchar* reaction)
{
	GeeArrayList* name_list = NULL;
	GeeArrayList* _tmp0_;
	GeeHashMap* _tmp1_;
	gpointer _tmp2_;
	GeeList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gboolean _tmp6_;
	GeeList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (reaction != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	name_list = _tmp0_;
	_tmp1_ = self->priv->reactions;
	_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, reaction);
	_tmp3_ = (GeeList*) _tmp2_;
	_tmp4_ = gee_collection_get_size ((GeeCollection*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_ > 0;
	_g_object_unref0 (_tmp3_);
	if (_tmp6_) {
		GeeHashMap* _tmp7_;
		gpointer _tmp8_;
		GeeList* _tmp9_;
		DinoEntitiesAccount* _tmp10_;
		XmppJid* _tmp11_;
		XmppJid* _tmp12_;
		XmppJid* _tmp13_;
		gboolean _tmp14_;
		_tmp7_ = self->priv->reactions;
		_tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp7_, reaction);
		_tmp9_ = (GeeList*) _tmp8_;
		_tmp10_ = self->priv->account;
		_tmp11_ = dino_entities_account_get_bare_jid (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = _tmp12_;
		_tmp14_ = gee_collection_contains ((GeeCollection*) _tmp9_, _tmp13_);
		_xmpp_jid_unref0 (_tmp13_);
		_g_object_unref0 (_tmp9_);
		if (_tmp14_) {
			GeeArrayList* _tmp15_;
			const gchar* _tmp16_;
			_tmp15_ = name_list;
			_tmp16_ = dino_gettext ("You");
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp15_, _tmp16_);
		}
		{
			GeeList* _jid_list = NULL;
			GeeHashMap* _tmp17_;
			gpointer _tmp18_;
			gint _jid_size = 0;
			GeeList* _tmp19_;
			gint _tmp20_;
			gint _tmp21_;
			gint _jid_index = 0;
			_tmp17_ = self->priv->reactions;
			_tmp18_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp17_, reaction);
			_jid_list = (GeeList*) _tmp18_;
			_tmp19_ = _jid_list;
			_tmp20_ = gee_collection_get_size ((GeeCollection*) _tmp19_);
			_tmp21_ = _tmp20_;
			_jid_size = _tmp21_;
			_jid_index = -1;
			while (TRUE) {
				gint _tmp22_;
				gint _tmp23_;
				XmppJid* jid = NULL;
				GeeList* _tmp24_;
				gpointer _tmp25_;
				XmppJid* _tmp26_;
				DinoEntitiesAccount* _tmp27_;
				XmppJid* _tmp28_;
				XmppJid* _tmp29_;
				XmppJid* _tmp30_;
				gboolean _tmp31_;
				GeeArrayList* _tmp32_;
				DinoStreamInteractor* _tmp33_;
				DinoEntitiesConversation* _tmp34_;
				XmppJid* _tmp35_;
				gchar* _tmp36_;
				gchar* _tmp37_;
				_jid_index = _jid_index + 1;
				_tmp22_ = _jid_index;
				_tmp23_ = _jid_size;
				if (!(_tmp22_ < _tmp23_)) {
					break;
				}
				_tmp24_ = _jid_list;
				_tmp25_ = gee_list_get (_tmp24_, _jid_index);
				jid = (XmppJid*) _tmp25_;
				_tmp26_ = jid;
				_tmp27_ = self->priv->account;
				_tmp28_ = dino_entities_account_get_bare_jid (_tmp27_);
				_tmp29_ = _tmp28_;
				_tmp30_ = _tmp29_;
				_tmp31_ = xmpp_jid_equals (_tmp26_, _tmp30_);
				_xmpp_jid_unref0 (_tmp30_);
				if (_tmp31_) {
					_xmpp_jid_unref0 (jid);
					continue;
				}
				_tmp32_ = name_list;
				_tmp33_ = self->priv->stream_interactor;
				_tmp34_ = self->priv->conversation;
				_tmp35_ = jid;
				_tmp36_ = dino_ui_util_get_participant_display_name (_tmp33_, _tmp34_, _tmp35_, FALSE);
				_tmp37_ = _tmp36_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp32_, _tmp37_);
				_g_free0 (_tmp37_);
				_xmpp_jid_unref0 (jid);
			}
			_g_object_unref0 (_jid_list);
		}
	}
	result = (GeeList*) name_list;
	return result;
}

static void
dino_ui_conversation_summary_reactions_controller_class_init (DinoUiConversationSummaryReactionsControllerClass * klass,
                                                              gpointer klass_data)
{
	dino_ui_conversation_summary_reactions_controller_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiConversationSummaryReactionsController_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dino_ui_conversation_summary_reactions_controller_finalize;
	dino_ui_conversation_summary_reactions_controller_signals[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_CONTROLLER_BOX_ACTIVATED_SIGNAL] = g_signal_new ("box-activated", DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_CONTROLLER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, gtk_widget_get_type ());
}

static void
dino_ui_conversation_summary_reactions_controller_instance_init (DinoUiConversationSummaryReactionsController * self,
                                                                 gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = dino_ui_conversation_summary_reactions_controller_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, GEE_TYPE_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->reactions = _tmp0_;
	self->priv->widget = NULL;
}

static void
dino_ui_conversation_summary_reactions_controller_finalize (GObject * obj)
{
	DinoUiConversationSummaryReactionsController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_CONTROLLER, DinoUiConversationSummaryReactionsController);
	_g_object_unref0 (self->priv->conversation);
	_g_object_unref0 (self->priv->account);
	_g_object_unref0 (self->priv->content_item);
	_g_object_unref0 (self->priv->stream_interactor);
	_g_object_unref0 (self->priv->reactions);
	_g_object_unref0 (self->priv->widget);
	G_OBJECT_CLASS (dino_ui_conversation_summary_reactions_controller_parent_class)->finalize (obj);
}

static GType
dino_ui_conversation_summary_reactions_controller_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiConversationSummaryReactionsControllerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_conversation_summary_reactions_controller_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiConversationSummaryReactionsController), 0, (GInstanceInitFunc) dino_ui_conversation_summary_reactions_controller_instance_init, NULL };
	GType dino_ui_conversation_summary_reactions_controller_type_id;
	dino_ui_conversation_summary_reactions_controller_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoUiConversationSummaryReactionsController", &g_define_type_info, 0);
	DinoUiConversationSummaryReactionsController_private_offset = g_type_add_instance_private (dino_ui_conversation_summary_reactions_controller_type_id, sizeof (DinoUiConversationSummaryReactionsControllerPrivate));
	return dino_ui_conversation_summary_reactions_controller_type_id;
}

GType
dino_ui_conversation_summary_reactions_controller_get_type (void)
{
	static volatile gsize dino_ui_conversation_summary_reactions_controller_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_conversation_summary_reactions_controller_type_id__once)) {
		GType dino_ui_conversation_summary_reactions_controller_type_id;
		dino_ui_conversation_summary_reactions_controller_type_id = dino_ui_conversation_summary_reactions_controller_get_type_once ();
		g_once_init_leave (&dino_ui_conversation_summary_reactions_controller_type_id__once, dino_ui_conversation_summary_reactions_controller_type_id);
	}
	return dino_ui_conversation_summary_reactions_controller_type_id__once;
}

static inline gpointer
dino_ui_conversation_summary_reactions_widget_get_instance_private (DinoUiConversationSummaryReactionsWidget* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiConversationSummaryReactionsWidget_private_offset);
}

static void
__lambda11_ (DinoUiConversationSummaryReactionsWidget* self,
             const gchar* emoji)
{
	g_return_if_fail (emoji != NULL);
	g_signal_emit (self, dino_ui_conversation_summary_reactions_widget_signals[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_EMOJI_PICKED_SIGNAL], 0, emoji);
}

static void
___lambda11__gtk_emoji_chooser_emoji_picked (GtkEmojiChooser* _sender,
                                             const gchar* text,
                                             gpointer self)
{
	__lambda11_ ((DinoUiConversationSummaryReactionsWidget*) self, text);
}

DinoUiConversationSummaryReactionsWidget*
dino_ui_conversation_summary_reactions_widget_construct (GType object_type)
{
	DinoUiConversationSummaryReactionsWidget * self = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	GtkMenuButton* _tmp2_ = NULL;
	GtkMenuButton* _tmp3_;
	GtkMenuButton* _tmp4_;
	GtkEmojiChooser* chooser = NULL;
	GtkEmojiChooser* _tmp5_;
	GtkMenuButton* _tmp6_;
	self = (DinoUiConversationSummaryReactionsWidget*) g_object_new (object_type, NULL);
	gtk_grid_set_column_spacing ((GtkGrid*) self, 5);
	gtk_grid_set_row_spacing ((GtkGrid*) self, 5);
	gtk_widget_set_margin_top ((GtkWidget*) self, 2);
	gtk_widget_add_css_class ((GtkWidget*) self, "reaction-grid");
	_tmp0_ = dino_gettext ("Add reaction");
	_tmp1_ = g_strdup (_tmp0_);
	_tmp2_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp2_, _tmp1_);
	_g_free0 (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->add_button);
	self->priv->add_button = _tmp2_;
	_tmp3_ = self->priv->add_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp3_, "pill");
	_tmp4_ = self->priv->add_button;
	dino_ui_util_menu_button_set_icon_with_size (_tmp4_, "dino-emoticon-add-symbolic", 14);
	_tmp5_ = (GtkEmojiChooser*) gtk_emoji_chooser_new ();
	g_object_ref_sink (_tmp5_);
	chooser = _tmp5_;
	g_signal_connect_object (chooser, "emoji-picked", (GCallback) ___lambda11__gtk_emoji_chooser_emoji_picked, self, 0);
	_tmp6_ = self->priv->add_button;
	gtk_menu_button_set_popover (_tmp6_, (GtkPopover*) chooser);
	_g_object_unref0 (chooser);
	return self;
}

DinoUiConversationSummaryReactionsWidget*
dino_ui_conversation_summary_reactions_widget_new (void)
{
	return dino_ui_conversation_summary_reactions_widget_construct (DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET);
}

static Block40Data*
block40_data_ref (Block40Data* _data40_)
{
	g_atomic_int_inc (&_data40_->_ref_count_);
	return _data40_;
}

static void
block40_data_unref (void * _userdata_)
{
	Block40Data* _data40_;
	_data40_ = (Block40Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data40_->_ref_count_)) {
		DinoUiConversationSummaryReactionsWidget* self;
		self = _data40_->self;
		_g_free0 (_data40_->reaction);
		_g_object_unref0 (self);
		g_slice_free (Block40Data, _data40_);
	}
}

static void
___lambda12_ (Block40Data* _data40_)
{
	DinoUiConversationSummaryReactionsWidget* self;
	self = _data40_->self;
	g_signal_emit (self, dino_ui_conversation_summary_reactions_widget_signals[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_EMOJI_CLICKED_SIGNAL], 0, _data40_->reaction);
}

static void
____lambda12__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	___lambda12_ (self);
}

void
dino_ui_conversation_summary_reactions_widget_update_reaction (DinoUiConversationSummaryReactionsWidget* self,
                                                               const gchar* reaction,
                                                               gint count,
                                                               gboolean own,
                                                               GeeList* names)
{
	Block40Data* _data40_;
	gchar* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp40_;
	gpointer _tmp41_;
	GtkLabel* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	GString* tooltip_builder = NULL;
	GString* _tmp55_;
	gint _tmp66_;
	gint _tmp67_;
	GString* _tmp69_;
	gint _tmp70_;
	gint _tmp71_;
	gpointer _tmp72_;
	gchar* _tmp73_;
	GString* _tmp74_;
	gchar* _tmp75_;
	gchar* _tmp76_;
	GeeHashMap* _tmp77_;
	gpointer _tmp78_;
	GtkButton* _tmp79_;
	GString* _tmp80_;
	const gchar* _tmp81_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (reaction != NULL);
	g_return_if_fail (names != NULL);
	_data40_ = g_slice_new0 (Block40Data);
	_data40_->_ref_count_ = 1;
	_data40_->self = g_object_ref (self);
	_tmp0_ = g_strdup (reaction);
	_g_free0 (_data40_->reaction);
	_data40_->reaction = _tmp0_;
	_tmp1_ = self->priv->reaction_buttons;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp1_, _data40_->reaction)) {
		GtkLabel* reaction_label = NULL;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		GtkLabel* _tmp6_ = NULL;
		GtkLabel* _tmp7_;
		GtkLabel* count_label = NULL;
		GtkLabel* _tmp8_ = NULL;
		GtkButton* button = NULL;
		GtkButton* _tmp9_;
		GtkButton* _tmp10_;
		GtkBox* reaction_box = NULL;
		GtkBox* _tmp11_ = NULL;
		GtkBox* _tmp12_;
		GtkLabel* _tmp13_;
		GtkBox* _tmp14_;
		GtkLabel* _tmp15_;
		GtkButton* _tmp16_;
		GtkBox* _tmp17_;
		GeeHashMap* _tmp18_;
		GtkLabel* _tmp19_;
		GeeHashMap* _tmp20_;
		GtkButton* _tmp21_;
		GtkButton* _tmp22_;
		GeeHashMap* _tmp23_;
		gint _tmp24_;
		gint _tmp25_;
		GeeHashMap* _tmp26_;
		gint _tmp27_;
		gint _tmp28_;
		GtkMenuButton* _tmp29_;
		GtkWidget* _tmp30_;
		GtkMenuButton* _tmp32_;
		GeeHashMap* _tmp33_;
		gint _tmp34_;
		gint _tmp35_;
		GeeHashMap* _tmp36_;
		gint _tmp37_;
		gint _tmp38_;
		GtkButton* _tmp39_;
		_tmp2_ = g_strconcat ("<span size='small'>", _data40_->reaction, NULL);
		_tmp3_ = _tmp2_;
		_tmp4_ = g_strconcat (_tmp3_, "</span>", NULL);
		_tmp5_ = _tmp4_;
		_tmp6_ = (GtkLabel*) gtk_label_new (_tmp5_);
		gtk_label_set_use_markup (_tmp6_, TRUE);
		g_object_ref_sink (_tmp6_);
		_tmp7_ = _tmp6_;
		_g_free0 (_tmp5_);
		_g_free0 (_tmp3_);
		reaction_label = _tmp7_;
		_tmp8_ = (GtkLabel*) gtk_label_new ("");
		gtk_label_set_use_markup (_tmp8_, TRUE);
		g_object_ref_sink (_tmp8_);
		count_label = _tmp8_;
		_tmp9_ = (GtkButton*) gtk_button_new ();
		g_object_ref_sink (_tmp9_);
		button = _tmp9_;
		_tmp10_ = button;
		gtk_widget_add_css_class ((GtkWidget*) _tmp10_, "pill");
		_tmp11_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
		gtk_widget_set_halign ((GtkWidget*) _tmp11_, GTK_ALIGN_CENTER);
		g_object_ref_sink (_tmp11_);
		reaction_box = _tmp11_;
		_tmp12_ = reaction_box;
		_tmp13_ = reaction_label;
		gtk_box_append (_tmp12_, (GtkWidget*) _tmp13_);
		_tmp14_ = reaction_box;
		_tmp15_ = count_label;
		gtk_box_append (_tmp14_, (GtkWidget*) _tmp15_);
		_tmp16_ = button;
		_tmp17_ = reaction_box;
		gtk_button_set_child (_tmp16_, (GtkWidget*) _tmp17_);
		_tmp18_ = self->priv->reaction_counts;
		_tmp19_ = count_label;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp18_, _data40_->reaction, _tmp19_);
		_tmp20_ = self->priv->reaction_buttons;
		_tmp21_ = button;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp20_, _data40_->reaction, _tmp21_);
		_tmp22_ = button;
		_tmp23_ = self->priv->reaction_buttons;
		_tmp24_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp23_);
		_tmp25_ = _tmp24_;
		_tmp26_ = self->priv->reaction_buttons;
		_tmp27_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp26_);
		_tmp28_ = _tmp27_;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp22_, (_tmp25_ - 1) % 10, (_tmp28_ - 1) / 10, 1, 1);
		_tmp29_ = self->priv->add_button;
		_tmp30_ = gtk_widget_get_parent ((GtkWidget*) _tmp29_);
		if (_tmp30_ != NULL) {
			GtkMenuButton* _tmp31_;
			_tmp31_ = self->priv->add_button;
			gtk_grid_remove ((GtkGrid*) self, (GtkWidget*) _tmp31_);
		}
		_tmp32_ = self->priv->add_button;
		_tmp33_ = self->priv->reaction_buttons;
		_tmp34_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp33_);
		_tmp35_ = _tmp34_;
		_tmp36_ = self->priv->reaction_buttons;
		_tmp37_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp36_);
		_tmp38_ = _tmp37_;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp32_, _tmp35_ % 10, _tmp38_ / 10, 1, 1);
		_tmp39_ = button;
		g_signal_connect_data (_tmp39_, "clicked", (GCallback) ____lambda12__gtk_button_clicked, block40_data_ref (_data40_), (GClosureNotify) block40_data_unref, 0);
		_g_object_unref0 (reaction_box);
		_g_object_unref0 (button);
		_g_object_unref0 (count_label);
		_g_object_unref0 (reaction_label);
	}
	_tmp40_ = self->priv->reaction_counts;
	_tmp41_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp40_, _data40_->reaction);
	_tmp42_ = (GtkLabel*) _tmp41_;
	_tmp43_ = g_strdup_printf ("%i", count);
	_tmp44_ = _tmp43_;
	_tmp45_ = g_strconcat ("<span font_family='monospace' size='small'>", _tmp44_, NULL);
	_tmp46_ = _tmp45_;
	_tmp47_ = g_strconcat (_tmp46_, "</span>", NULL);
	_tmp48_ = _tmp47_;
	gtk_label_set_label (_tmp42_, _tmp48_);
	_g_free0 (_tmp48_);
	_g_free0 (_tmp46_);
	_g_free0 (_tmp44_);
	_g_object_unref0 (_tmp42_);
	if (own) {
		GeeHashMap* _tmp49_;
		gpointer _tmp50_;
		GtkButton* _tmp51_;
		_tmp49_ = self->priv->reaction_buttons;
		_tmp50_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp49_, _data40_->reaction);
		_tmp51_ = (GtkButton*) _tmp50_;
		gtk_widget_add_css_class ((GtkWidget*) _tmp51_, "own-reaction");
		_g_object_unref0 (_tmp51_);
	} else {
		GeeHashMap* _tmp52_;
		gpointer _tmp53_;
		GtkButton* _tmp54_;
		_tmp52_ = self->priv->reaction_buttons;
		_tmp53_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp52_, _data40_->reaction);
		_tmp54_ = (GtkButton*) _tmp53_;
		gtk_widget_remove_css_class ((GtkWidget*) _tmp54_, "own-reaction");
		_g_object_unref0 (_tmp54_);
	}
	_tmp55_ = g_string_new ("");
	tooltip_builder = _tmp55_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp56_ = FALSE;
			_tmp56_ = TRUE;
			while (TRUE) {
				gint _tmp58_;
				gint _tmp59_;
				GString* _tmp60_;
				gpointer _tmp61_;
				gchar* _tmp62_;
				gint _tmp63_;
				gint _tmp64_;
				if (!_tmp56_) {
					gint _tmp57_;
					_tmp57_ = i;
					i = _tmp57_ + 1;
				}
				_tmp56_ = FALSE;
				_tmp58_ = gee_collection_get_size ((GeeCollection*) names);
				_tmp59_ = _tmp58_;
				if (!(i < (_tmp59_ - 1))) {
					break;
				}
				_tmp60_ = tooltip_builder;
				_tmp61_ = gee_list_get (names, i);
				_tmp62_ = (gchar*) _tmp61_;
				g_string_append (_tmp60_, _tmp62_);
				_g_free0 (_tmp62_);
				_tmp63_ = gee_collection_get_size ((GeeCollection*) names);
				_tmp64_ = _tmp63_;
				if (i < (_tmp64_ - 2)) {
					GString* _tmp65_;
					_tmp65_ = tooltip_builder;
					g_string_append (_tmp65_, ", ");
				}
			}
		}
	}
	_tmp66_ = gee_collection_get_size ((GeeCollection*) names);
	_tmp67_ = _tmp66_;
	if (_tmp67_ > 1) {
		GString* _tmp68_;
		_tmp68_ = tooltip_builder;
		g_string_append (_tmp68_, " and ");
	}
	_tmp69_ = tooltip_builder;
	_tmp70_ = gee_collection_get_size ((GeeCollection*) names);
	_tmp71_ = _tmp70_;
	_tmp72_ = gee_list_get (names, _tmp71_ - 1);
	_tmp73_ = (gchar*) _tmp72_;
	g_string_append (_tmp69_, _tmp73_);
	_g_free0 (_tmp73_);
	_tmp74_ = tooltip_builder;
	_tmp75_ = g_strconcat (" reacted with ", _data40_->reaction, NULL);
	_tmp76_ = _tmp75_;
	g_string_append (_tmp74_, _tmp76_);
	_g_free0 (_tmp76_);
	_tmp77_ = self->priv->reaction_buttons;
	_tmp78_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp77_, _data40_->reaction);
	_tmp79_ = (GtkButton*) _tmp78_;
	_tmp80_ = tooltip_builder;
	_tmp81_ = _tmp80_->str;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp79_, _tmp81_);
	_g_object_unref0 (_tmp79_);
	_g_string_free0 (tooltip_builder);
	block40_data_unref (_data40_);
	_data40_ = NULL;
}

void
dino_ui_conversation_summary_reactions_widget_remove_reaction (DinoUiConversationSummaryReactionsWidget* self,
                                                               const gchar* reaction)
{
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	GtkButton* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (reaction != NULL);
	_tmp0_ = self->priv->reaction_buttons;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, reaction);
	_tmp2_ = (GtkButton*) _tmp1_;
	gtk_widget_unparent ((GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
}

static void
dino_ui_conversation_summary_reactions_widget_class_init (DinoUiConversationSummaryReactionsWidgetClass * klass,
                                                          gpointer klass_data)
{
	dino_ui_conversation_summary_reactions_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiConversationSummaryReactionsWidget_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dino_ui_conversation_summary_reactions_widget_finalize;
	dino_ui_conversation_summary_reactions_widget_signals[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_EMOJI_PICKED_SIGNAL] = g_signal_new ("emoji-picked", DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	dino_ui_conversation_summary_reactions_widget_signals[DINO_UI_CONVERSATION_SUMMARY_REACTIONS_WIDGET_EMOJI_CLICKED_SIGNAL] = g_signal_new ("emoji-clicked", DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}

static void
dino_ui_conversation_summary_reactions_widget_instance_init (DinoUiConversationSummaryReactionsWidget * self,
                                                             gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	self->priv = dino_ui_conversation_summary_reactions_widget_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, gtk_label_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->reaction_counts = _tmp0_;
	_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, gtk_button_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->reaction_buttons = _tmp1_;
}

static void
dino_ui_conversation_summary_reactions_widget_finalize (GObject * obj)
{
	DinoUiConversationSummaryReactionsWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_CONVERSATION_SUMMARY_TYPE_REACTIONS_WIDGET, DinoUiConversationSummaryReactionsWidget);
	_g_object_unref0 (self->priv->reaction_counts);
	_g_object_unref0 (self->priv->reaction_buttons);
	_g_object_unref0 (self->priv->add_button);
	G_OBJECT_CLASS (dino_ui_conversation_summary_reactions_widget_parent_class)->finalize (obj);
}

static GType
dino_ui_conversation_summary_reactions_widget_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiConversationSummaryReactionsWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_conversation_summary_reactions_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiConversationSummaryReactionsWidget), 0, (GInstanceInitFunc) dino_ui_conversation_summary_reactions_widget_instance_init, NULL };
	GType dino_ui_conversation_summary_reactions_widget_type_id;
	dino_ui_conversation_summary_reactions_widget_type_id = g_type_register_static (gtk_grid_get_type (), "DinoUiConversationSummaryReactionsWidget", &g_define_type_info, 0);
	DinoUiConversationSummaryReactionsWidget_private_offset = g_type_add_instance_private (dino_ui_conversation_summary_reactions_widget_type_id, sizeof (DinoUiConversationSummaryReactionsWidgetPrivate));
	return dino_ui_conversation_summary_reactions_widget_type_id;
}

GType
dino_ui_conversation_summary_reactions_widget_get_type (void)
{
	static volatile gsize dino_ui_conversation_summary_reactions_widget_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_conversation_summary_reactions_widget_type_id__once)) {
		GType dino_ui_conversation_summary_reactions_widget_type_id;
		dino_ui_conversation_summary_reactions_widget_type_id = dino_ui_conversation_summary_reactions_widget_get_type_once ();
		g_once_init_leave (&dino_ui_conversation_summary_reactions_widget_type_id__once, dino_ui_conversation_summary_reactions_widget_type_id);
	}
	return dino_ui_conversation_summary_reactions_widget_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;
}

