/* menu_entry.c generated by valac 0.56.19, the Vala compiler
 * generated from menu_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 <gio/gio.h>
#include "dino_i18n.h"
#include <adwaita.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_MENU_ENTRY (dino_ui_menu_entry_get_type ())
#define DINO_UI_MENU_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_MENU_ENTRY, DinoUiMenuEntry))
#define DINO_UI_MENU_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_MENU_ENTRY, DinoUiMenuEntryClass))
#define DINO_UI_IS_MENU_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_MENU_ENTRY))
#define DINO_UI_IS_MENU_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_MENU_ENTRY))
#define DINO_UI_MENU_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_MENU_ENTRY, DinoUiMenuEntryClass))

typedef struct _DinoUiMenuEntry DinoUiMenuEntry;
typedef struct _DinoUiMenuEntryClass DinoUiMenuEntryClass;
typedef struct _DinoUiMenuEntryPrivate DinoUiMenuEntryPrivate;
enum  {
	DINO_UI_MENU_ENTRY_0_PROPERTY,
	DINO_UI_MENU_ENTRY_ID_PROPERTY,
	DINO_UI_MENU_ENTRY_ORDER_PROPERTY,
	DINO_UI_MENU_ENTRY_NUM_PROPERTIES
};
static GParamSpec* dino_ui_menu_entry_properties[DINO_UI_MENU_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))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))

#define DINO_UI_CONVERSATION_DETAILS_TYPE_DIALOG (dino_ui_conversation_details_dialog_get_type ())
#define DINO_UI_CONVERSATION_DETAILS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_CONVERSATION_DETAILS_TYPE_DIALOG, DinoUiConversationDetailsDialog))
#define DINO_UI_CONVERSATION_DETAILS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_CONVERSATION_DETAILS_TYPE_DIALOG, DinoUiConversationDetailsDialogClass))
#define DINO_UI_CONVERSATION_DETAILS_IS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_CONVERSATION_DETAILS_TYPE_DIALOG))
#define DINO_UI_CONVERSATION_DETAILS_IS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_CONVERSATION_DETAILS_TYPE_DIALOG))
#define DINO_UI_CONVERSATION_DETAILS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_CONVERSATION_DETAILS_TYPE_DIALOG, DinoUiConversationDetailsDialogClass))

typedef struct _DinoUiConversationDetailsDialog DinoUiConversationDetailsDialog;
typedef struct _DinoUiConversationDetailsDialogClass DinoUiConversationDetailsDialogClass;

struct _DinoUiMenuEntry {
	GObject parent_instance;
	DinoUiMenuEntryPrivate * priv;
};

struct _DinoUiMenuEntryClass {
	GObjectClass parent_class;
};

struct _DinoUiMenuEntryPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoEntitiesConversation* conversation;
	GtkMenuButton* button;
};

static gint DinoUiMenuEntry_private_offset;
static gpointer dino_ui_menu_entry_parent_class = NULL;
static DinoPluginsConversationTitlebarEntryIface * dino_ui_menu_entry_dino_plugins_conversation_titlebar_entry_parent_iface = NULL;

VALA_EXTERN GType dino_ui_menu_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiMenuEntry, g_object_unref)
VALA_EXTERN DinoUiMenuEntry* dino_ui_menu_entry_new (DinoStreamInteractor* stream_interactor);
VALA_EXTERN DinoUiMenuEntry* dino_ui_menu_entry_construct (GType object_type,
                                               DinoStreamInteractor* stream_interactor);
static void __lambda214_ (DinoUiMenuEntry* self,
                   GVariant* parameter);
static void ___lambda214__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void dino_ui_menu_entry_real_set_conversation (DinoPluginsConversationTitlebarEntry* base,
                                               DinoEntitiesConversation* conversation);
static void dino_ui_menu_entry_real_unset_conversation (DinoPluginsConversationTitlebarEntry* base);
static void dino_ui_menu_entry_open_conversation_details (DinoUiMenuEntry* self);
VALA_EXTERN GType dino_ui_conversation_details_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiConversationDetailsDialog, g_object_unref)
VALA_EXTERN DinoUiConversationDetailsDialog* dino_ui_conversation_details_setup_dialog (DinoEntitiesConversation* conversation,
                                                                            DinoStreamInteractor* stream_interactor,
                                                                            GtkWindow* parent);
static GObject* dino_ui_menu_entry_real_get_widget (DinoPluginsConversationTitlebarEntry* base,
                                             DinoPluginsWidgetType type);
static void dino_ui_menu_entry_finalize (GObject * obj);
static GType dino_ui_menu_entry_get_type_once (void);
static void _vala_dino_ui_menu_entry_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_ui_menu_entry_get_instance_private (DinoUiMenuEntry* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiMenuEntry_private_offset);
}

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

static void
__lambda214_ (DinoUiMenuEntry* self,
              GVariant* parameter)
{
	GVariant* variant = NULL;
	DinoEntitiesConversation* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GVariant* _tmp3_;
	GVariant* _tmp4_;
	GVariant** _tmp5_;
	GVariant** _tmp6_;
	gint _tmp6__length1;
	GVariant* _tmp7_;
	GVariant* _tmp8_;
	GApplication* _tmp9_;
	_tmp0_ = self->priv->conversation;
	_tmp1_ = dino_entities_conversation_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_variant_new_int32 ((gint32) _tmp2_);
	g_variant_ref_sink (_tmp3_);
	_tmp4_ = g_variant_new_string ("about");
	g_variant_ref_sink (_tmp4_);
	_tmp5_ = g_new0 (GVariant*, 2 + 1);
	_tmp5_[0] = _tmp3_;
	_tmp5_[1] = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp6__length1 = 2;
	_tmp7_ = g_variant_new_tuple (_tmp6_, 2);
	g_variant_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_variant_unref), NULL);
	variant = _tmp8_;
	_tmp9_ = g_application_get_default ();
	g_action_group_activate_action ((GActionGroup*) _tmp9_, "open-conversation-details", variant);
	_g_variant_unref0 (variant);
}

static void
___lambda214__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda214_ ((DinoUiMenuEntry*) self, parameter);
}

DinoUiMenuEntry*
dino_ui_menu_entry_construct (GType object_type,
                              DinoStreamInteractor* stream_interactor)
{
	DinoUiMenuEntry * self = NULL;
	DinoStreamInteractor* _tmp0_;
	GMenu* menu_model = NULL;
	GMenu* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GtkPopoverMenu* popover_menu = NULL;
	GtkPopoverMenu* _tmp4_;
	GtkMenuButton* _tmp5_;
	GSimpleActionGroup* action_group = NULL;
	GSimpleActionGroup* _tmp6_;
	GSimpleAction* details_action = NULL;
	GSimpleAction* _tmp7_;
	GtkMenuButton* _tmp8_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	self = (DinoUiMenuEntry*) 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_ = g_menu_new ();
	menu_model = _tmp1_;
	_tmp2_ = dino_gettext ("Conversation Details");
	g_menu_append (menu_model, _tmp2_, "conversation.details");
	_tmp3_ = dino_gettext ("Close Conversation");
	g_menu_append (menu_model, _tmp3_, "app.close-current-conversation");
	_tmp4_ = (GtkPopoverMenu*) gtk_popover_menu_new_from_model ((GMenuModel*) menu_model);
	g_object_ref_sink (_tmp4_);
	popover_menu = _tmp4_;
	_tmp5_ = self->priv->button;
	gtk_menu_button_set_popover (_tmp5_, (GtkPopover*) popover_menu);
	_tmp6_ = g_simple_action_group_new ();
	action_group = _tmp6_;
	_tmp7_ = g_simple_action_new ("details", NULL);
	details_action = _tmp7_;
	g_signal_connect_object (details_action, "activate", (GCallback) ___lambda214__g_simple_action_activate, self, 0);
	g_simple_action_group_insert (action_group, (GAction*) details_action);
	_tmp8_ = self->priv->button;
	gtk_widget_insert_action_group ((GtkWidget*) _tmp8_, "conversation", (GActionGroup*) action_group);
	_g_object_unref0 (details_action);
	_g_object_unref0 (action_group);
	_g_object_unref0 (popover_menu);
	_g_object_unref0 (menu_model);
	return self;
}

DinoUiMenuEntry*
dino_ui_menu_entry_new (DinoStreamInteractor* stream_interactor)
{
	return dino_ui_menu_entry_construct (DINO_UI_TYPE_MENU_ENTRY, stream_interactor);
}

static void
dino_ui_menu_entry_real_set_conversation (DinoPluginsConversationTitlebarEntry* base,
                                          DinoEntitiesConversation* conversation)
{
	DinoUiMenuEntry * self;
	GtkMenuButton* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	self = (DinoUiMenuEntry*) base;
	g_return_if_fail (conversation != NULL);
	_tmp0_ = self->priv->button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, TRUE);
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (self->priv->conversation);
	self->priv->conversation = _tmp1_;
}

static void
dino_ui_menu_entry_real_unset_conversation (DinoPluginsConversationTitlebarEntry* base)
{
	DinoUiMenuEntry * self;
	GtkMenuButton* _tmp0_;
	self = (DinoUiMenuEntry*) base;
	_tmp0_ = self->priv->button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, FALSE);
}

static void
dino_ui_menu_entry_open_conversation_details (DinoUiMenuEntry* self)
{
	DinoUiConversationDetailsDialog* conversation_details = NULL;
	DinoEntitiesConversation* _tmp0_;
	DinoStreamInteractor* _tmp1_;
	GtkMenuButton* _tmp2_;
	GtkRoot* _tmp3_;
	DinoUiConversationDetailsDialog* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->conversation;
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = self->priv->button;
	_tmp3_ = gtk_widget_get_root ((GtkWidget*) _tmp2_);
	_tmp4_ = dino_ui_conversation_details_setup_dialog (_tmp0_, _tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_window_get_type (), GtkWindow));
	conversation_details = _tmp4_;
	gtk_window_present ((GtkWindow*) conversation_details);
	_g_object_unref0 (conversation_details);
}

static GObject*
dino_ui_menu_entry_real_get_widget (DinoPluginsConversationTitlebarEntry* base,
                                    DinoPluginsWidgetType type)
{
	DinoUiMenuEntry * self;
	GtkMenuButton* _tmp0_;
	GObject* _tmp1_;
	GObject* result;
	self = (DinoUiMenuEntry*) 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_menu_entry_real_get_id (DinoPluginsConversationTitlebarEntry* base)
{
	const gchar* result;
	DinoUiMenuEntry* self;
	self = (DinoUiMenuEntry*) base;
	result = "menu";
	return result;
}

static gdouble
dino_ui_menu_entry_real_get_order (DinoPluginsConversationTitlebarEntry* base)
{
	gdouble result;
	DinoUiMenuEntry* self;
	self = (DinoUiMenuEntry*) base;
	result = (gdouble) 0;
	return result;
}

static void
dino_ui_menu_entry_class_init (DinoUiMenuEntryClass * klass,
                               gpointer klass_data)
{
	dino_ui_menu_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiMenuEntry_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_ui_menu_entry_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_ui_menu_entry_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_UI_MENU_ENTRY_ID_PROPERTY, dino_ui_menu_entry_properties[DINO_UI_MENU_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_MENU_ENTRY_ORDER_PROPERTY, dino_ui_menu_entry_properties[DINO_UI_MENU_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_menu_entry_dino_plugins_conversation_titlebar_entry_interface_init (DinoPluginsConversationTitlebarEntryIface * iface,
                                                                            gpointer iface_data)
{
	dino_ui_menu_entry_dino_plugins_conversation_titlebar_entry_parent_iface = g_type_interface_peek_parent (iface);
	iface->set_conversation = (void (*) (DinoPluginsConversationTitlebarEntry*, DinoEntitiesConversation*)) dino_ui_menu_entry_real_set_conversation;
	iface->unset_conversation = (void (*) (DinoPluginsConversationTitlebarEntry*)) dino_ui_menu_entry_real_unset_conversation;
	iface->get_widget = (GObject* (*) (DinoPluginsConversationTitlebarEntry*, DinoPluginsWidgetType)) dino_ui_menu_entry_real_get_widget;
	iface->get_id = dino_ui_menu_entry_real_get_id;
	iface->get_order = dino_ui_menu_entry_real_get_order;
}

static void
dino_ui_menu_entry_instance_init (DinoUiMenuEntry * self,
                                  gpointer klass)
{
	gchar* _tmp0_;
	GtkMenuButton* _tmp1_ = NULL;
	self->priv = dino_ui_menu_entry_get_instance_private (self);
	_tmp0_ = g_strdup ("view-more-symbolic");
	_tmp1_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_menu_button_set_icon_name (_tmp1_, _tmp0_);
	_g_free0 (_tmp0_);
	g_object_ref_sink (_tmp1_);
	self->priv->button = _tmp1_;
}

static void
dino_ui_menu_entry_finalize (GObject * obj)
{
	DinoUiMenuEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_TYPE_MENU_ENTRY, DinoUiMenuEntry);
	_g_object_unref0 (self->priv->stream_interactor);
	_g_object_unref0 (self->priv->conversation);
	_g_object_unref0 (self->priv->button);
	G_OBJECT_CLASS (dino_ui_menu_entry_parent_class)->finalize (obj);
}

static GType
dino_ui_menu_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiMenuEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_menu_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiMenuEntry), 0, (GInstanceInitFunc) dino_ui_menu_entry_instance_init, NULL };
	static const GInterfaceInfo dino_plugins_conversation_titlebar_entry_info = { (GInterfaceInitFunc) dino_ui_menu_entry_dino_plugins_conversation_titlebar_entry_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_ui_menu_entry_type_id;
	dino_ui_menu_entry_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoUiMenuEntry", &g_define_type_info, 0);
	g_type_add_interface_static (dino_ui_menu_entry_type_id, DINO_PLUGINS_TYPE_CONVERSATION_TITLEBAR_ENTRY, &dino_plugins_conversation_titlebar_entry_info);
	DinoUiMenuEntry_private_offset = g_type_add_instance_private (dino_ui_menu_entry_type_id, sizeof (DinoUiMenuEntryPrivate));
	return dino_ui_menu_entry_type_id;
}

GType
dino_ui_menu_entry_get_type (void)
{
	static volatile gsize dino_ui_menu_entry_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_menu_entry_type_id__once)) {
		GType dino_ui_menu_entry_type_id;
		dino_ui_menu_entry_type_id = dino_ui_menu_entry_get_type_once ();
		g_once_init_leave (&dino_ui_menu_entry_type_id__once, dino_ui_menu_entry_type_id);
	}
	return dino_ui_menu_entry_type_id__once;
}

static void
_vala_dino_ui_menu_entry_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	DinoUiMenuEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_UI_TYPE_MENU_ENTRY, DinoUiMenuEntry);
	switch (property_id) {
		case DINO_UI_MENU_ENTRY_ID_PROPERTY:
		g_value_set_string (value, dino_plugins_conversation_titlebar_entry_get_id ((DinoPluginsConversationTitlebarEntry*) self));
		break;
		case DINO_UI_MENU_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 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 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;
}

