/* more-info-button.c generated by valac 0.56.19, the Vala compiler
 * generated from more-info-button.vala, do not modify */

/* more-info-button.vala
 * 
 * Copyright 2025 Will Warner
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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 TYPE_MORE_INFO_BUTTON (more_info_button_get_type ())
#define MORE_INFO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MORE_INFO_BUTTON, MoreInfoButton))
#define MORE_INFO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MORE_INFO_BUTTON, MoreInfoButtonClass))
#define IS_MORE_INFO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MORE_INFO_BUTTON))
#define IS_MORE_INFO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MORE_INFO_BUTTON))
#define MORE_INFO_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MORE_INFO_BUTTON, MoreInfoButtonClass))

typedef struct _MoreInfoButton MoreInfoButton;
typedef struct _MoreInfoButtonClass MoreInfoButtonClass;
typedef struct _MoreInfoButtonPrivate MoreInfoButtonPrivate;
enum  {
	MORE_INFO_BUTTON_0_PROPERTY,
	MORE_INFO_BUTTON_TEXT_PROPERTY,
	MORE_INFO_BUTTON_EXTRA_CHILD_PROPERTY,
	MORE_INFO_BUTTON_NUM_PROPERTIES
};
static GParamSpec* more_info_button_properties[MORE_INFO_BUTTON_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _MoreInfoButton {
	AdwBin parent_instance;
	MoreInfoButtonPrivate * priv;
};

struct _MoreInfoButtonClass {
	AdwBinClass parent_class;
};

struct _MoreInfoButtonPrivate {
	GtkWidget* button;
	GtkLabel* info_label;
	AdwBin* extra_widget_bin;
	gchar* _text;
};

static gint MoreInfoButton_private_offset;
static gpointer more_info_button_parent_class = NULL;

VALA_EXTERN GType more_info_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MoreInfoButton, g_object_unref)
VALA_EXTERN MoreInfoButton* more_info_button_new (void);
VALA_EXTERN MoreInfoButton* more_info_button_construct (GType object_type);
VALA_EXTERN const gchar* more_info_button_get_text (MoreInfoButton* self);
VALA_EXTERN void more_info_button_set_text (MoreInfoButton* self,
                                const gchar* value);
VALA_EXTERN GtkWidget* more_info_button_get_extra_child (MoreInfoButton* self);
VALA_EXTERN void more_info_button_set_extra_child (MoreInfoButton* self,
                                       GtkWidget* value);
static GObject * more_info_button_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
static void _more_info_button___lambda4_ (MoreInfoButton* self);
static void __more_info_button___lambda4__g_object_notify (GObject* _sender,
                                                    GParamSpec* pspec,
                                                    gpointer self);
static void more_info_button_finalize (GObject * obj);
static GType more_info_button_get_type_once (void);
static void _vala_more_info_button_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_more_info_button_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);

static inline gpointer
more_info_button_get_instance_private (MoreInfoButton* self)
{
	return G_STRUCT_MEMBER_P (self, MoreInfoButton_private_offset);
}

MoreInfoButton*
more_info_button_construct (GType object_type)
{
	MoreInfoButton * self = NULL;
	self = (MoreInfoButton*) g_object_new (object_type, NULL);
	return self;
}

MoreInfoButton*
more_info_button_new (void)
{
	return more_info_button_construct (TYPE_MORE_INFO_BUTTON);
}

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

void
more_info_button_set_text (MoreInfoButton* self,
                           const gchar* value)
{
	GtkLabel* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	if (value == NULL) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("");
		_g_free0 (self->priv->_text);
		self->priv->_text = _tmp0_;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup (value);
		_g_free0 (self->priv->_text);
		self->priv->_text = _tmp1_;
	}
	_tmp2_ = self->priv->info_label;
	_tmp3_ = self->priv->_text;
	gtk_label_set_label (_tmp2_, _tmp3_);
	g_object_notify_by_pspec ((GObject *) self, more_info_button_properties[MORE_INFO_BUTTON_TEXT_PROPERTY]);
}

GtkWidget*
more_info_button_get_extra_child (MoreInfoButton* self)
{
	GtkWidget* result;
	AdwBin* _tmp0_;
	GtkWidget* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->extra_widget_bin;
	_tmp1_ = adw_bin_get_child (_tmp0_);
	result = _tmp1_;
	return result;
}

void
more_info_button_set_extra_child (MoreInfoButton* self,
                                  GtkWidget* value)
{
	AdwBin* _tmp2_;
	g_return_if_fail (self != NULL);
	if (value == NULL) {
		AdwBin* _tmp0_;
		_tmp0_ = self->priv->extra_widget_bin;
		gtk_widget_set_visible ((GtkWidget*) _tmp0_, FALSE);
	} else {
		AdwBin* _tmp1_;
		_tmp1_ = self->priv->extra_widget_bin;
		gtk_widget_set_visible ((GtkWidget*) _tmp1_, TRUE);
	}
	_tmp2_ = self->priv->extra_widget_bin;
	adw_bin_set_child (_tmp2_, value);
	g_object_notify_by_pspec ((GObject *) self, more_info_button_properties[MORE_INFO_BUTTON_EXTRA_CHILD_PROPERTY]);
}

static void
_more_info_button___lambda4_ (MoreInfoButton* self)
{
	GtkWidget* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->button;
	_tmp1_ = gtk_menu_button_get_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_menu_button_get_type (), GtkMenuButton));
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		const gchar* _tmp3_;
		_tmp3_ = self->priv->_text;
		gtk_accessible_announce ((GtkAccessible*) self, _tmp3_, GTK_ACCESSIBLE_ANNOUNCEMENT_PRIORITY_MEDIUM);
	}
}

static void
__more_info_button___lambda4__g_object_notify (GObject* _sender,
                                               GParamSpec* pspec,
                                               gpointer self)
{
	_more_info_button___lambda4_ ((MoreInfoButton*) self);
}

static GObject *
more_info_button_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	MoreInfoButton * self;
	GtkWidget* _tmp0_;
	parent_class = G_OBJECT_CLASS (more_info_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MORE_INFO_BUTTON, MoreInfoButton);
	_tmp0_ = self->priv->button;
	g_signal_connect_object ((GObject*) _tmp0_, "notify::active", (GCallback) __more_info_button___lambda4__g_object_notify, self, 0);
	return obj;
}

static void
more_info_button_class_init (MoreInfoButtonClass * klass,
                             gpointer klass_data)
{
	more_info_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MoreInfoButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_more_info_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_more_info_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = more_info_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = more_info_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), MORE_INFO_BUTTON_TEXT_PROPERTY, more_info_button_properties[MORE_INFO_BUTTON_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MORE_INFO_BUTTON_EXTRA_CHILD_PROPERTY, more_info_button_properties[MORE_INFO_BUTTON_EXTRA_CHILD_PROPERTY] = g_param_spec_object ("extra-child", "extra-child", "extra-child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Quadrapassel/more-info-button.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "button", FALSE, MoreInfoButton_private_offset + G_STRUCT_OFFSET (MoreInfoButtonPrivate, button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "info_label", FALSE, MoreInfoButton_private_offset + G_STRUCT_OFFSET (MoreInfoButtonPrivate, info_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "extra_widget_bin", FALSE, MoreInfoButton_private_offset + G_STRUCT_OFFSET (MoreInfoButtonPrivate, extra_widget_bin));
}

static void
more_info_button_instance_init (MoreInfoButton * self,
                                gpointer klass)
{
	gchar* _tmp0_;
	self->priv = more_info_button_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_text = _tmp0_;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
more_info_button_finalize (GObject * obj)
{
	MoreInfoButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MORE_INFO_BUTTON, MoreInfoButton);
	_g_free0 (self->priv->_text);
	G_OBJECT_CLASS (more_info_button_parent_class)->finalize (obj);
}

static GType
more_info_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MoreInfoButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) more_info_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MoreInfoButton), 0, (GInstanceInitFunc) more_info_button_instance_init, NULL };
	GType more_info_button_type_id;
	more_info_button_type_id = g_type_register_static (adw_bin_get_type (), "MoreInfoButton", &g_define_type_info, 0);
	MoreInfoButton_private_offset = g_type_add_instance_private (more_info_button_type_id, sizeof (MoreInfoButtonPrivate));
	return more_info_button_type_id;
}

GType
more_info_button_get_type (void)
{
	static volatile gsize more_info_button_type_id__once = 0;
	if (g_once_init_enter (&more_info_button_type_id__once)) {
		GType more_info_button_type_id;
		more_info_button_type_id = more_info_button_get_type_once ();
		g_once_init_leave (&more_info_button_type_id__once, more_info_button_type_id);
	}
	return more_info_button_type_id__once;
}

static void
_vala_more_info_button_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	MoreInfoButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MORE_INFO_BUTTON, MoreInfoButton);
	switch (property_id) {
		case MORE_INFO_BUTTON_TEXT_PROPERTY:
		g_value_set_string (value, more_info_button_get_text (self));
		break;
		case MORE_INFO_BUTTON_EXTRA_CHILD_PROPERTY:
		g_value_set_object (value, more_info_button_get_extra_child (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_more_info_button_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	MoreInfoButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_MORE_INFO_BUTTON, MoreInfoButton);
	switch (property_id) {
		case MORE_INFO_BUTTON_TEXT_PROPERTY:
		more_info_button_set_text (self, g_value_get_string (value));
		break;
		case MORE_INFO_BUTTON_EXTRA_CHILD_PROPERTY:
		more_info_button_set_extra_child (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

