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

/*
* SPDX-License-Identifier: GPL-2.0-or-later
* SPDX-FileCopyrightText: 2017-2023 elementary, Inc. (https://elementary.io)
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <granite.h>
#include <atk/atk.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 CODE_TYPE_POPOVER_MENU_ITEM (code_popover_menu_item_get_type ())
#define CODE_POPOVER_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CODE_TYPE_POPOVER_MENU_ITEM, CodePopoverMenuItem))
#define CODE_POPOVER_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CODE_TYPE_POPOVER_MENU_ITEM, CodePopoverMenuItemClass))
#define CODE_IS_POPOVER_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CODE_TYPE_POPOVER_MENU_ITEM))
#define CODE_IS_POPOVER_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CODE_TYPE_POPOVER_MENU_ITEM))
#define CODE_POPOVER_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CODE_TYPE_POPOVER_MENU_ITEM, CodePopoverMenuItemClass))

typedef struct _CodePopoverMenuItem CodePopoverMenuItem;
typedef struct _CodePopoverMenuItemClass CodePopoverMenuItemClass;
typedef struct _CodePopoverMenuItemPrivate CodePopoverMenuItemPrivate;
enum  {
	CODE_POPOVER_MENU_ITEM_0_PROPERTY,
	CODE_POPOVER_MENU_ITEM_TEXT_PROPERTY,
	CODE_POPOVER_MENU_ITEM_ICON_NAME_PROPERTY,
	CODE_POPOVER_MENU_ITEM_NUM_PROPERTIES
};
static GParamSpec* code_popover_menu_item_properties[CODE_POPOVER_MENU_ITEM_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _CodePopoverMenuItem {
	GtkButton parent_instance;
	CodePopoverMenuItemPrivate * priv;
};

struct _CodePopoverMenuItemClass {
	GtkButtonClass parent_class;
};

struct _CodePopoverMenuItemPrivate {
	gchar* _text;
	gchar* _icon_name;
};

static gint CodePopoverMenuItem_private_offset;
static gpointer code_popover_menu_item_parent_class = NULL;

VALA_EXTERN GType code_popover_menu_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CodePopoverMenuItem, g_object_unref)
VALA_EXTERN CodePopoverMenuItem* code_popover_menu_item_new (const gchar* text);
VALA_EXTERN CodePopoverMenuItem* code_popover_menu_item_construct (GType object_type,
                                                       const gchar* text);
VALA_EXTERN const gchar* code_popover_menu_item_get_text (CodePopoverMenuItem* self);
static void code_popover_menu_item_set_text (CodePopoverMenuItem* self,
                                      const gchar* value);
VALA_EXTERN const gchar* code_popover_menu_item_get_icon_name (CodePopoverMenuItem* self);
VALA_EXTERN void code_popover_menu_item_set_icon_name (CodePopoverMenuItem* self,
                                           const gchar* value);
static GObject * code_popover_menu_item_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void _code_popover_menu_item___lambda163_ (CodePopoverMenuItem* self);
static void __code_popover_menu_item___lambda163__gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self);
static void code_popover_menu_item_finalize (GObject * obj);
static GType code_popover_menu_item_get_type_once (void);
static void _vala_code_popover_menu_item_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_code_popover_menu_item_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);

static inline gpointer
code_popover_menu_item_get_instance_private (CodePopoverMenuItem* self)
{
	return G_STRUCT_MEMBER_P (self, CodePopoverMenuItem_private_offset);
}

CodePopoverMenuItem*
code_popover_menu_item_construct (GType object_type,
                                  const gchar* text)
{
	CodePopoverMenuItem * self = NULL;
	g_return_val_if_fail (text != NULL, NULL);
	self = (CodePopoverMenuItem*) g_object_new (object_type, "text", text, NULL);
	return self;
}

CodePopoverMenuItem*
code_popover_menu_item_new (const gchar* text)
{
	return code_popover_menu_item_construct (CODE_TYPE_POPOVER_MENU_ITEM, text);
}

const gchar*
code_popover_menu_item_get_text (CodePopoverMenuItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_text;
	result = _tmp0_;
	return result;
}

static void
code_popover_menu_item_set_text (CodePopoverMenuItem* self,
                                 const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = code_popover_menu_item_get_text (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_text);
		self->priv->_text = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, code_popover_menu_item_properties[CODE_POPOVER_MENU_ITEM_TEXT_PROPERTY]);
	}
}

const gchar*
code_popover_menu_item_get_icon_name (CodePopoverMenuItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_icon_name;
	result = _tmp0_;
	return result;
}

void
code_popover_menu_item_set_icon_name (CodePopoverMenuItem* self,
                                      const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = code_popover_menu_item_get_icon_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_icon_name);
		self->priv->_icon_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, code_popover_menu_item_properties[CODE_POPOVER_MENU_ITEM_ICON_NAME_PROPERTY]);
	}
}

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

static void
_code_popover_menu_item___lambda163_ (CodePopoverMenuItem* self)
{
	GtkPopover* popover = NULL;
	GtkWidget* _tmp0_;
	GtkPopover* _tmp1_;
	GtkPopover* _tmp2_;
	_tmp0_ = gtk_widget_get_ancestor ((GtkWidget*) self, gtk_popover_get_type ());
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_popover_get_type (), GtkPopover));
	popover = _tmp1_;
	_tmp2_ = popover;
	if (_tmp2_ != NULL) {
		GtkPopover* _tmp3_;
		_tmp3_ = popover;
		gtk_popover_popdown (_tmp3_);
	}
	_g_object_unref0 (popover);
}

static void
__code_popover_menu_item___lambda163__gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self)
{
	_code_popover_menu_item___lambda163_ ((CodePopoverMenuItem*) self);
}

static GObject *
code_popover_menu_item_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	CodePopoverMenuItem * self;
	GtkImage* image = NULL;
	GtkImage* _tmp0_;
	GraniteAccelLabel* label = NULL;
	const gchar* _tmp1_;
	GraniteAccelLabel* _tmp2_;
	GtkBox* box = NULL;
	GtkBox* _tmp3_;
	GtkBox* _tmp4_;
	GtkImage* _tmp5_;
	GtkBox* _tmp6_;
	GraniteAccelLabel* _tmp7_;
	GtkBox* _tmp8_;
	AtkObject* _tmp9_;
	GraniteAccelLabel* _tmp10_;
	GtkImage* _tmp11_;
	parent_class = G_OBJECT_CLASS (code_popover_menu_item_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CODE_TYPE_POPOVER_MENU_ITEM, CodePopoverMenuItem);
	_tmp0_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp0_);
	image = _tmp0_;
	_tmp1_ = self->priv->_text;
	_tmp2_ = granite_accel_label_new (_tmp1_, NULL);
	g_object_ref_sink (_tmp2_);
	label = _tmp2_;
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp3_);
	box = _tmp3_;
	_tmp4_ = box;
	_tmp5_ = image;
	gtk_container_add ((GtkContainer*) _tmp4_, (GtkWidget*) _tmp5_);
	_tmp6_ = box;
	_tmp7_ = label;
	gtk_container_add ((GtkContainer*) _tmp6_, (GtkWidget*) _tmp7_);
	_tmp8_ = box;
	g_object_set ((GtkContainer*) self, "child", (GtkWidget*) _tmp8_, NULL);
	_tmp9_ = gtk_widget_get_accessible ((GtkWidget*) self);
	g_object_set (_tmp9_, "accessible-role", ATK_ROLE_MENU_ITEM, NULL);
	g_signal_connect_object ((GtkButton*) self, "clicked", (GCallback) __code_popover_menu_item___lambda163__gtk_button_clicked, self, 0);
	_tmp10_ = label;
	g_object_bind_property_with_closures ((GObject*) self, "action-name", (GObject*) _tmp10_, "action-name", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp11_ = image;
	g_object_bind_property_with_closures ((GObject*) self, "icon-name", (GObject*) _tmp11_, "icon-name", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_g_object_unref0 (box);
	_g_object_unref0 (label);
	_g_object_unref0 (image);
	return obj;
}

static void
code_popover_menu_item_base_init (CodePopoverMenuItemClass * klass)
{
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "modelbutton");
}

static void
code_popover_menu_item_class_init (CodePopoverMenuItemClass * klass,
                                   gpointer klass_data)
{
	code_popover_menu_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CodePopoverMenuItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_code_popover_menu_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_code_popover_menu_item_set_property;
	G_OBJECT_CLASS (klass)->constructor = code_popover_menu_item_constructor;
	G_OBJECT_CLASS (klass)->finalize = code_popover_menu_item_finalize;
	/**
	     * The label for the button
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CODE_POPOVER_MENU_ITEM_TEXT_PROPERTY, code_popover_menu_item_properties[CODE_POPOVER_MENU_ITEM_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	/**
	     * The icon name for the button
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CODE_POPOVER_MENU_ITEM_ICON_NAME_PROPERTY, code_popover_menu_item_properties[CODE_POPOVER_MENU_ITEM_ICON_NAME_PROPERTY] = g_param_spec_string ("icon-name", "icon-name", "icon-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
code_popover_menu_item_instance_init (CodePopoverMenuItem * self,
                                      gpointer klass)
{
	self->priv = code_popover_menu_item_get_instance_private (self);
}

static void
code_popover_menu_item_finalize (GObject * obj)
{
	CodePopoverMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CODE_TYPE_POPOVER_MENU_ITEM, CodePopoverMenuItem);
	_g_free0 (self->priv->_text);
	_g_free0 (self->priv->_icon_name);
	G_OBJECT_CLASS (code_popover_menu_item_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
code_popover_menu_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CodePopoverMenuItemClass), (GBaseInitFunc) code_popover_menu_item_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) code_popover_menu_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CodePopoverMenuItem), 0, (GInstanceInitFunc) code_popover_menu_item_instance_init, NULL };
	GType code_popover_menu_item_type_id;
	code_popover_menu_item_type_id = g_type_register_static (gtk_button_get_type (), "CodePopoverMenuItem", &g_define_type_info, G_TYPE_FLAG_NONE);
	CodePopoverMenuItem_private_offset = g_type_add_instance_private (code_popover_menu_item_type_id, sizeof (CodePopoverMenuItemPrivate));
	return code_popover_menu_item_type_id;
}

GType
code_popover_menu_item_get_type (void)
{
	static gsize code_popover_menu_item_type_id__once = 0;
	if (g_once_init_enter (&code_popover_menu_item_type_id__once)) {
		GType code_popover_menu_item_type_id;
		code_popover_menu_item_type_id = code_popover_menu_item_get_type_once ();
		g_once_init_leave (&code_popover_menu_item_type_id__once, code_popover_menu_item_type_id);
	}
	return code_popover_menu_item_type_id__once;
}

static void
_vala_code_popover_menu_item_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	CodePopoverMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CODE_TYPE_POPOVER_MENU_ITEM, CodePopoverMenuItem);
	switch (property_id) {
		case CODE_POPOVER_MENU_ITEM_TEXT_PROPERTY:
		g_value_set_string (value, code_popover_menu_item_get_text (self));
		break;
		case CODE_POPOVER_MENU_ITEM_ICON_NAME_PROPERTY:
		g_value_set_string (value, code_popover_menu_item_get_icon_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_code_popover_menu_item_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	CodePopoverMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CODE_TYPE_POPOVER_MENU_ITEM, CodePopoverMenuItem);
	switch (property_id) {
		case CODE_POPOVER_MENU_ITEM_TEXT_PROPERTY:
		code_popover_menu_item_set_text (self, g_value_get_string (value));
		break;
		case CODE_POPOVER_MENU_ITEM_ICON_NAME_PROPERTY:
		code_popover_menu_item_set_icon_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

