/* 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 "wingpanel-9.h"
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <granite-7.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

enum  {
	WINGPANEL_POPOVER_MENU_ITEM_0_PROPERTY,
	WINGPANEL_POPOVER_MENU_ITEM_TEXT_PROPERTY,
	WINGPANEL_POPOVER_MENU_ITEM_NUM_PROPERTIES
};
static GParamSpec* wingpanel_popover_menu_item_properties[WINGPANEL_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)))

static gpointer wingpanel_popover_menu_item_parent_class = NULL;

static GObject * wingpanel_popover_menu_item_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties);
static void _wingpanel_popover_menu_item___lambda7_ (WingpanelPopoverMenuItem* self);
static void __wingpanel_popover_menu_item___lambda7__gtk_button_clicked (GtkButton* _sender,
                                                                  gpointer self);
static GType wingpanel_popover_menu_item_get_type_once (void);
static void _vala_wingpanel_popover_menu_item_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec);

WingpanelPopoverMenuItem*
wingpanel_popover_menu_item_construct (GType object_type)
{
	WingpanelPopoverMenuItem * self = NULL;
	self = (WingpanelPopoverMenuItem*) g_object_new (object_type, NULL);
	return self;
}

WingpanelPopoverMenuItem*
wingpanel_popover_menu_item_new (void)
{
	return wingpanel_popover_menu_item_construct (WINGPANEL_TYPE_POPOVER_MENU_ITEM);
}

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

WingpanelPopoverMenuItem*
wingpanel_popover_menu_item_new_with_text (const gchar* text)
{
	return wingpanel_popover_menu_item_construct_with_text (WINGPANEL_TYPE_POPOVER_MENU_ITEM, text);
}

void
wingpanel_popover_menu_item_set_text (WingpanelPopoverMenuItem* self,
                                      const gchar* value)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GraniteAccelLabel* _tmp3_ = NULL;
	GraniteAccelLabel* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_actionable_get_action_name ((GtkActionable*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	_tmp3_ = granite_accel_label_new (value, NULL);
	granite_accel_label_set_action_name (_tmp3_, _tmp2_);
	_g_free0 (_tmp2_);
	g_object_ref_sink (_tmp3_);
	_tmp4_ = _tmp3_;
	gtk_button_set_child ((GtkButton*) self, (GtkWidget*) _tmp4_);
	_g_object_unref0 (_tmp4_);
	gtk_accessible_update_property ((GtkAccessible*) self, GTK_ACCESSIBLE_PROPERTY_LABEL, value, -1, -1);
	g_object_notify_by_pspec ((GObject *) self, wingpanel_popover_menu_item_properties[WINGPANEL_POPOVER_MENU_ITEM_TEXT_PROPERTY]);
}

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

static void
_wingpanel_popover_menu_item___lambda7_ (WingpanelPopoverMenuItem* 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
__wingpanel_popover_menu_item___lambda7__gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self)
{
	_wingpanel_popover_menu_item___lambda7_ ((WingpanelPopoverMenuItem*) self);
}

static GObject *
wingpanel_popover_menu_item_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WingpanelPopoverMenuItem * self;
	parent_class = G_OBJECT_CLASS (wingpanel_popover_menu_item_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WINGPANEL_TYPE_POPOVER_MENU_ITEM, WingpanelPopoverMenuItem);
	g_object_set ((GtkAccessible*) self, "accessible-role", GTK_ACCESSIBLE_ROLE_MENU_ITEM, NULL);
	g_signal_connect_object ((GtkButton*) self, "clicked", (GCallback) __wingpanel_popover_menu_item___lambda7__gtk_button_clicked, self, 0);
	return obj;
}

static void
wingpanel_popover_menu_item_base_init (WingpanelPopoverMenuItemClass * klass)
{
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "modelbutton");
}

static void
wingpanel_popover_menu_item_class_init (WingpanelPopoverMenuItemClass * klass,
                                        gpointer klass_data)
{
	wingpanel_popover_menu_item_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->set_property = _vala_wingpanel_popover_menu_item_set_property;
	G_OBJECT_CLASS (klass)->constructor = wingpanel_popover_menu_item_constructor;
	/**
	     * The label for the button
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), WINGPANEL_POPOVER_MENU_ITEM_TEXT_PROPERTY, wingpanel_popover_menu_item_properties[WINGPANEL_POPOVER_MENU_ITEM_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
}

static void
wingpanel_popover_menu_item_instance_init (WingpanelPopoverMenuItem * self,
                                           gpointer klass)
{
}

/**
 * PopoverMenuItem is a {@link Gtk.Button} subclass for use as a MenuItem in {@link Gtk.Popover}
 *
 * It will automatically call {@link Gtk.Popover.popdown} on its parent when clicked
 *
 * It contains a {@link Granite.AccelLabel} which will automatically show
 * accelerators for the {@link GLib.Action} assigned to #this
 *
 * @since 8.0.0
 */
static GType
wingpanel_popover_menu_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WingpanelPopoverMenuItemClass), (GBaseInitFunc) wingpanel_popover_menu_item_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wingpanel_popover_menu_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WingpanelPopoverMenuItem), 0, (GInstanceInitFunc) wingpanel_popover_menu_item_instance_init, NULL };
	GType wingpanel_popover_menu_item_type_id;
	wingpanel_popover_menu_item_type_id = g_type_register_static (gtk_button_get_type (), "WingpanelPopoverMenuItem", &g_define_type_info, 0);
	return wingpanel_popover_menu_item_type_id;
}

GType
wingpanel_popover_menu_item_get_type (void)
{
	static volatile gsize wingpanel_popover_menu_item_type_id__once = 0;
	if (g_once_init_enter (&wingpanel_popover_menu_item_type_id__once)) {
		GType wingpanel_popover_menu_item_type_id;
		wingpanel_popover_menu_item_type_id = wingpanel_popover_menu_item_get_type_once ();
		g_once_init_leave (&wingpanel_popover_menu_item_type_id__once, wingpanel_popover_menu_item_type_id);
	}
	return wingpanel_popover_menu_item_type_id__once;
}

static void
_vala_wingpanel_popover_menu_item_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	WingpanelPopoverMenuItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WINGPANEL_TYPE_POPOVER_MENU_ITEM, WingpanelPopoverMenuItem);
	switch (property_id) {
		case WINGPANEL_POPOVER_MENU_ITEM_TEXT_PROPERTY:
		wingpanel_popover_menu_item_set_text (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

