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

#include <glib-object.h>
#include "libdino.h"
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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_TYPE_OCCUPANTS_ENTRY (dino_ui_occupants_entry_get_type ())
#define DINO_UI_OCCUPANTS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_OCCUPANTS_ENTRY, DinoUiOccupantsEntry))
#define DINO_UI_OCCUPANTS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_OCCUPANTS_ENTRY, DinoUiOccupantsEntryClass))
#define DINO_UI_IS_OCCUPANTS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_OCCUPANTS_ENTRY))
#define DINO_UI_IS_OCCUPANTS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_OCCUPANTS_ENTRY))
#define DINO_UI_OCCUPANTS_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_OCCUPANTS_ENTRY, DinoUiOccupantsEntryClass))

typedef struct _DinoUiOccupantsEntry DinoUiOccupantsEntry;
typedef struct _DinoUiOccupantsEntryClass DinoUiOccupantsEntryClass;
typedef struct _DinoUiOccupantsEntryPrivate DinoUiOccupantsEntryPrivate;

#define DINO_UI_OCCUPANT_MENU_TYPE_VIEW (dino_ui_occupant_menu_view_get_type ())
#define DINO_UI_OCCUPANT_MENU_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_OCCUPANT_MENU_TYPE_VIEW, DinoUiOccupantMenuView))
#define DINO_UI_OCCUPANT_MENU_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_OCCUPANT_MENU_TYPE_VIEW, DinoUiOccupantMenuViewClass))
#define DINO_UI_OCCUPANT_MENU_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_OCCUPANT_MENU_TYPE_VIEW))
#define DINO_UI_OCCUPANT_MENU_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_OCCUPANT_MENU_TYPE_VIEW))
#define DINO_UI_OCCUPANT_MENU_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_OCCUPANT_MENU_TYPE_VIEW, DinoUiOccupantMenuViewClass))

typedef struct _DinoUiOccupantMenuView DinoUiOccupantMenuView;
typedef struct _DinoUiOccupantMenuViewClass DinoUiOccupantMenuViewClass;
enum  {
	DINO_UI_OCCUPANTS_ENTRY_0_PROPERTY,
	DINO_UI_OCCUPANTS_ENTRY_ID_PROPERTY,
	DINO_UI_OCCUPANTS_ENTRY_ORDER_PROPERTY,
	DINO_UI_OCCUPANTS_ENTRY_NUM_PROPERTIES
};
static GParamSpec* dino_ui_occupants_entry_properties[DINO_UI_OCCUPANTS_ENTRY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _DinoUiOccupantsEntry {
	GObject parent_instance;
	DinoUiOccupantsEntryPrivate * priv;
};

struct _DinoUiOccupantsEntryClass {
	GObjectClass parent_class;
};

struct _DinoUiOccupantsEntryPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoEntitiesConversation* conversation;
	GtkMenuButton* button;
	DinoUiOccupantMenuView* menu;
};

static gint DinoUiOccupantsEntry_private_offset;
static gpointer dino_ui_occupants_entry_parent_class = NULL;
static DinoPluginsConversationTitlebarEntryIface * dino_ui_occupants_entry_dino_plugins_conversation_titlebar_entry_parent_iface = NULL;

VALA_EXTERN GType dino_ui_occupants_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiOccupantsEntry, g_object_unref)
VALA_EXTERN GType dino_ui_occupant_menu_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiOccupantMenuView, g_object_unref)
VALA_EXTERN gchar* dino_ui_util_string_if_tooltips_active (const gchar* s);
VALA_EXTERN DinoUiOccupantsEntry* dino_ui_occupants_entry_new (DinoStreamInteractor* stream_interactor);
VALA_EXTERN DinoUiOccupantsEntry* dino_ui_occupants_entry_construct (GType object_type,
                                                         DinoStreamInteractor* stream_interactor);
static void dino_ui_occupants_entry_real_set_conversation (DinoPluginsConversationTitlebarEntry* base,
                                                    DinoEntitiesConversation* conversation);
VALA_EXTERN DinoUiOccupantMenuView* dino_ui_occupant_menu_view_new (DinoStreamInteractor* stream_interactor,
                                                        DinoEntitiesConversation* conversation);
VALA_EXTERN DinoUiOccupantMenuView* dino_ui_occupant_menu_view_construct (GType object_type,
                                                              DinoStreamInteractor* stream_interactor,
                                                              DinoEntitiesConversation* conversation);
static void dino_ui_occupants_entry_real_unset_conversation (DinoPluginsConversationTitlebarEntry* base);
static GObject* dino_ui_occupants_entry_real_get_widget (DinoPluginsConversationTitlebarEntry* base,
                                                  DinoPluginsWidgetType type);
static void dino_ui_occupants_entry_finalize (GObject * obj);
static GType dino_ui_occupants_entry_get_type_once (void);
static void _vala_dino_ui_occupants_entry_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_ui_occupants_entry_get_instance_private (DinoUiOccupantsEntry* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiOccupantsEntry_private_offset);
}

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

DinoUiOccupantsEntry*
dino_ui_occupants_entry_construct (GType object_type,
                                   DinoStreamInteractor* stream_interactor)
{
	DinoUiOccupantsEntry * self = NULL;
	DinoStreamInteractor* _tmp0_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	self = (DinoUiOccupantsEntry*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	return self;
}

DinoUiOccupantsEntry*
dino_ui_occupants_entry_new (DinoStreamInteractor* stream_interactor)
{
	return dino_ui_occupants_entry_construct (DINO_UI_TYPE_OCCUPANTS_ENTRY, stream_interactor);
}

static void
dino_ui_occupants_entry_real_set_conversation (DinoPluginsConversationTitlebarEntry* base,
                                               DinoEntitiesConversation* conversation)
{
	DinoUiOccupantsEntry * self;
	DinoEntitiesConversation* _tmp0_;
	DinoEntitiesConversationType _tmp1_;
	DinoEntitiesConversationType _tmp2_;
	self = (DinoUiOccupantsEntry*) base;
	g_return_if_fail (conversation != NULL);
	_tmp0_ = _g_object_ref0 (conversation);
	_g_object_unref0 (self->priv->conversation);
	self->priv->conversation = _tmp0_;
	_tmp1_ = dino_entities_conversation_get_type_ (conversation);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT) {
		GtkMenuButton* _tmp3_;
		DinoUiOccupantMenuView* new_menu = NULL;
		DinoStreamInteractor* _tmp4_;
		DinoUiOccupantMenuView* _tmp5_;
		GtkMenuButton* _tmp6_;
		DinoUiOccupantMenuView* _tmp7_;
		DinoUiOccupantMenuView* _tmp8_;
		DinoUiOccupantMenuView* _tmp9_;
		_tmp3_ = self->priv->button;
		gtk_widget_set_visible ((GtkWidget*) _tmp3_, TRUE);
		_tmp4_ = self->priv->stream_interactor;
		_tmp5_ = dino_ui_occupant_menu_view_new (_tmp4_, conversation);
		g_object_ref_sink (_tmp5_);
		new_menu = _tmp5_;
		_tmp6_ = self->priv->button;
		_tmp7_ = new_menu;
		gtk_menu_button_set_popover (_tmp6_, (GtkPopover*) _tmp7_);
		_tmp8_ = new_menu;
		_tmp9_ = _g_object_ref0 (_tmp8_);
		_g_object_unref0 (self->priv->menu);
		self->priv->menu = _tmp9_;
		_g_object_unref0 (new_menu);
	} else {
		GtkMenuButton* _tmp10_;
		_tmp10_ = self->priv->button;
		gtk_widget_set_visible ((GtkWidget*) _tmp10_, FALSE);
	}
}

static void
dino_ui_occupants_entry_real_unset_conversation (DinoPluginsConversationTitlebarEntry* base)
{
	DinoUiOccupantsEntry * self;
	GtkMenuButton* _tmp0_;
	self = (DinoUiOccupantsEntry*) base;
	_tmp0_ = self->priv->button;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, FALSE);
}

static GObject*
dino_ui_occupants_entry_real_get_widget (DinoPluginsConversationTitlebarEntry* base,
                                         DinoPluginsWidgetType type)
{
	DinoUiOccupantsEntry * self;
	GtkMenuButton* _tmp0_;
	GObject* _tmp1_;
	GObject* result;
	self = (DinoUiOccupantsEntry*) base;
	if (type != DINO_PLUGINS_WIDGET_TYPE_GTK4) {
		result = NULL;
		return result;
	}
	_tmp0_ = self->priv->button;
	_tmp1_ = _g_object_ref0 ((GObject*) _tmp0_);
	result = _tmp1_;
	return result;
}

static const gchar*
dino_ui_occupants_entry_real_get_id (DinoPluginsConversationTitlebarEntry* base)
{
	const gchar* result;
	DinoUiOccupantsEntry* self;
	self = (DinoUiOccupantsEntry*) base;
	result = "occupants";
	return result;
}

static gdouble
dino_ui_occupants_entry_real_get_order (DinoPluginsConversationTitlebarEntry* base)
{
	gdouble result;
	DinoUiOccupantsEntry* self;
	self = (DinoUiOccupantsEntry*) base;
	result = (gdouble) 3;
	return result;
}

static void
dino_ui_occupants_entry_class_init (DinoUiOccupantsEntryClass * klass,
                                    gpointer klass_data)
{
	dino_ui_occupants_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiOccupantsEntry_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_ui_occupants_entry_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_ui_occupants_entry_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_UI_OCCUPANTS_ENTRY_ID_PROPERTY, dino_ui_occupants_entry_properties[DINO_UI_OCCUPANTS_ENTRY_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_UI_OCCUPANTS_ENTRY_ORDER_PROPERTY, dino_ui_occupants_entry_properties[DINO_UI_OCCUPANTS_ENTRY_ORDER_PROPERTY] = g_param_spec_double ("order", "order", "order", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dino_ui_occupants_entry_dino_plugins_conversation_titlebar_entry_interface_init (DinoPluginsConversationTitlebarEntryIface * iface,
                                                                                 gpointer iface_data)
{
	dino_ui_occupants_entry_dino_plugins_conversation_titlebar_entry_parent_iface = g_type_interface_peek_parent (iface);
	iface->set_conversation = (void (*) (DinoPluginsConversationTitlebarEntry*, DinoEntitiesConversation*)) dino_ui_occupants_entry_real_set_conversation;
	iface->unset_conversation = (void (*) (DinoPluginsConversationTitlebarEntry*)) dino_ui_occupants_entry_real_unset_conversation;
	iface->get_widget = (GObject* (*) (DinoPluginsConversationTitlebarEntry*, DinoPluginsWidgetType)) dino_ui_occupants_entry_real_get_widget;
	iface->get_id = dino_ui_occupants_entry_real_get_id;
	iface->get_order = dino_ui_occupants_entry_real_get_order;
}

static void
dino_ui_occupants_entry_instance_init (DinoUiOccupantsEntry * self,
                                       gpointer klass)
{
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GtkMenuButton* _tmp3_ = NULL;
	self->priv = dino_ui_occupants_entry_get_instance_private (self);
	_tmp0_ = g_strdup ("system-users-symbolic");
	_tmp1_ = dino_gettext ("Members");
	_tmp2_ = dino_ui_util_string_if_tooltips_active (_tmp1_);
	_tmp3_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_menu_button_set_icon_name (_tmp3_, _tmp0_);
	_g_free0 (_tmp0_);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp3_, _tmp2_);
	_g_free0 (_tmp2_);
	gtk_widget_set_visible ((GtkWidget*) _tmp3_, FALSE);
	g_object_ref_sink (_tmp3_);
	self->priv->button = _tmp3_;
	self->priv->menu = NULL;
}

static void
dino_ui_occupants_entry_finalize (GObject * obj)
{
	DinoUiOccupantsEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_TYPE_OCCUPANTS_ENTRY, DinoUiOccupantsEntry);
	_g_object_unref0 (self->priv->stream_interactor);
	_g_object_unref0 (self->priv->conversation);
	_g_object_unref0 (self->priv->button);
	_g_object_unref0 (self->priv->menu);
	G_OBJECT_CLASS (dino_ui_occupants_entry_parent_class)->finalize (obj);
}

static GType
dino_ui_occupants_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiOccupantsEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_occupants_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiOccupantsEntry), 0, (GInstanceInitFunc) dino_ui_occupants_entry_instance_init, NULL };
	static const GInterfaceInfo dino_plugins_conversation_titlebar_entry_info = { (GInterfaceInitFunc) dino_ui_occupants_entry_dino_plugins_conversation_titlebar_entry_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_ui_occupants_entry_type_id;
	dino_ui_occupants_entry_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoUiOccupantsEntry", &g_define_type_info, 0);
	g_type_add_interface_static (dino_ui_occupants_entry_type_id, DINO_PLUGINS_TYPE_CONVERSATION_TITLEBAR_ENTRY, &dino_plugins_conversation_titlebar_entry_info);
	DinoUiOccupantsEntry_private_offset = g_type_add_instance_private (dino_ui_occupants_entry_type_id, sizeof (DinoUiOccupantsEntryPrivate));
	return dino_ui_occupants_entry_type_id;
}

GType
dino_ui_occupants_entry_get_type (void)
{
	static volatile gsize dino_ui_occupants_entry_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_occupants_entry_type_id__once)) {
		GType dino_ui_occupants_entry_type_id;
		dino_ui_occupants_entry_type_id = dino_ui_occupants_entry_get_type_once ();
		g_once_init_leave (&dino_ui_occupants_entry_type_id__once, dino_ui_occupants_entry_type_id);
	}
	return dino_ui_occupants_entry_type_id__once;
}

static void
_vala_dino_ui_occupants_entry_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	DinoUiOccupantsEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_UI_TYPE_OCCUPANTS_ENTRY, DinoUiOccupantsEntry);
	switch (property_id) {
		case DINO_UI_OCCUPANTS_ENTRY_ID_PROPERTY:
		g_value_set_string (value, dino_plugins_conversation_titlebar_entry_get_id ((DinoPluginsConversationTitlebarEntry*) self));
		break;
		case DINO_UI_OCCUPANTS_ENTRY_ORDER_PROPERTY:
		g_value_set_double (value, dino_plugins_conversation_titlebar_entry_get_order ((DinoPluginsConversationTitlebarEntry*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

