/* toast.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from toast.vala, do not modify */

/* This file is part of GNOME Boxes. License: LGPLv2+*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.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 BOXES_TYPE_TOAST (boxes_toast_get_type ())
#define BOXES_TOAST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_TOAST, BoxesToast))
#define BOXES_TOAST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_TOAST, BoxesToastClass))
#define BOXES_IS_TOAST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_TOAST))
#define BOXES_IS_TOAST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_TOAST))
#define BOXES_TOAST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_TOAST, BoxesToastClass))

typedef struct _BoxesToast BoxesToast;
typedef struct _BoxesToastClass BoxesToastClass;
typedef struct _BoxesToastPrivate BoxesToastPrivate;
typedef void (*BoxesToastOKFunc) (gpointer user_data);
typedef void (*BoxesToastDismissFunc) (gpointer user_data);
enum  {
	BOXES_TOAST_0_PROPERTY,
	BOXES_TOAST_MESSAGE_PROPERTY,
	BOXES_TOAST_ACTION_PROPERTY,
	BOXES_TOAST_NUM_PROPERTIES
};
static GParamSpec* boxes_toast_properties[BOXES_TOAST_NUM_PROPERTIES];

struct _BoxesToast {
	GtkBox parent_instance;
	BoxesToastPrivate * priv;
	BoxesToastOKFunc undo_func;
	gpointer undo_func_target;
	GDestroyNotify undo_func_target_destroy_notify;
	BoxesToastDismissFunc dismiss_func;
	gpointer dismiss_func_target;
	GDestroyNotify dismiss_func_target_destroy_notify;
};

struct _BoxesToastClass {
	GtkBoxClass parent_class;
};

struct _BoxesToastPrivate {
	GtkLabel* label;
	GtkButton* button;
};

static gint BoxesToast_private_offset;
static gpointer boxes_toast_parent_class = NULL;

VALA_EXTERN GType boxes_toast_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesToast, g_object_unref)
VALA_EXTERN BoxesToast* boxes_toast_new (const gchar* message);
VALA_EXTERN BoxesToast* boxes_toast_construct (GType object_type,
                                   const gchar* message);
VALA_EXTERN void boxes_toast_set_message (BoxesToast* self,
                              const gchar* value);
VALA_EXTERN void boxes_toast_dismiss (BoxesToast* self);
static void boxes_toast_on_dismiss_button_clicked (BoxesToast* self);
static void _boxes_toast_on_dismiss_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                gpointer self);
static void boxes_toast_on_undo_button_clicked (BoxesToast* self);
static void _boxes_toast_on_undo_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self);
static void boxes_toast_real_destroy (GtkWidget* base);
VALA_EXTERN const gchar* boxes_toast_get_message (BoxesToast* self);
VALA_EXTERN const gchar* boxes_toast_get_action (BoxesToast* self);
VALA_EXTERN void boxes_toast_set_action (BoxesToast* self,
                             const gchar* value);
static void boxes_toast_finalize (GObject * obj);
static GType boxes_toast_get_type_once (void);
static void _vala_boxes_toast_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_boxes_toast_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec);

static inline gpointer
boxes_toast_get_instance_private (BoxesToast* self)
{
	return G_STRUCT_MEMBER_P (self, BoxesToast_private_offset);
}

BoxesToast*
boxes_toast_construct (GType object_type,
                       const gchar* message)
{
	BoxesToast * self = NULL;
	self = (BoxesToast*) g_object_new (object_type, NULL);
	if (message != NULL) {
		boxes_toast_set_message (self, message);
	}
	return self;
}

BoxesToast*
boxes_toast_new (const gchar* message)
{
	return boxes_toast_construct (BOXES_TYPE_TOAST, message);
}

void
boxes_toast_dismiss (BoxesToast* self)
{
	BoxesToastDismissFunc _tmp0_;
	gpointer _tmp0__target;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->dismiss_func;
	_tmp0__target = self->dismiss_func_target;
	if (_tmp0_ != NULL) {
		BoxesToastDismissFunc _tmp1_;
		gpointer _tmp1__target;
		_tmp1_ = self->dismiss_func;
		_tmp1__target = self->dismiss_func_target;
		_tmp1_ (_tmp1__target);
	}
	gtk_widget_destroy ((GtkWidget*) self);
}

static void
boxes_toast_on_dismiss_button_clicked (BoxesToast* self)
{
	g_return_if_fail (self != NULL);
	boxes_toast_dismiss (self);
}

static void
_boxes_toast_on_dismiss_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                           gpointer self)
{
	boxes_toast_on_dismiss_button_clicked ((BoxesToast*) self);
}

static void
boxes_toast_on_undo_button_clicked (BoxesToast* self)
{
	BoxesToastOKFunc _tmp0_;
	gpointer _tmp0__target;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->undo_func;
	_tmp0__target = self->undo_func_target;
	if (_tmp0_ != NULL) {
		BoxesToastOKFunc _tmp1_;
		gpointer _tmp1__target;
		_tmp1_ = self->undo_func;
		_tmp1__target = self->undo_func_target;
		_tmp1_ (_tmp1__target);
	}
	gtk_widget_destroy ((GtkWidget*) self);
}

static void
_boxes_toast_on_undo_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self)
{
	boxes_toast_on_undo_button_clicked ((BoxesToast*) self);
}

static void
boxes_toast_real_destroy (GtkWidget* base)
{
	BoxesToast * self;
	self = (BoxesToast*) base;
	(self->dismiss_func_target_destroy_notify == NULL) ? NULL : (self->dismiss_func_target_destroy_notify (self->dismiss_func_target), NULL);
	self->dismiss_func = NULL;
	self->dismiss_func_target = NULL;
	self->dismiss_func_target_destroy_notify = NULL;
	self->dismiss_func = NULL;
	self->dismiss_func_target = NULL;
	self->dismiss_func_target_destroy_notify = NULL;
	(self->undo_func_target_destroy_notify == NULL) ? NULL : (self->undo_func_target_destroy_notify (self->undo_func_target), NULL);
	self->undo_func = NULL;
	self->undo_func_target = NULL;
	self->undo_func_target_destroy_notify = NULL;
	self->undo_func = NULL;
	self->undo_func_target = NULL;
	self->undo_func_target_destroy_notify = NULL;
	GTK_WIDGET_CLASS (boxes_toast_parent_class)->destroy ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox));
}

const gchar*
boxes_toast_get_message (BoxesToast* self)
{
	const gchar* result;
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->label;
	_tmp1_ = gtk_label_get_label (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
boxes_toast_set_message (BoxesToast* self,
                         const gchar* value)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->label;
	gtk_label_set_label (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, boxes_toast_properties[BOXES_TOAST_MESSAGE_PROPERTY]);
}

const gchar*
boxes_toast_get_action (BoxesToast* self)
{
	const gchar* result;
	GtkButton* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->button;
	_tmp1_ = gtk_button_get_label (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
boxes_toast_set_action (BoxesToast* self,
                        const gchar* value)
{
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->button;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, TRUE);
	_tmp1_ = self->priv->button;
	gtk_button_set_label (_tmp1_, value);
	g_object_notify_by_pspec ((GObject *) self, boxes_toast_properties[BOXES_TOAST_ACTION_PROPERTY]);
}

static void
boxes_toast_class_init (BoxesToastClass * klass,
                        gpointer klass_data)
{
	boxes_toast_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BoxesToast_private_offset);
	((GtkWidgetClass *) klass)->destroy = (void (*) (GtkWidget*)) boxes_toast_real_destroy;
	G_OBJECT_CLASS (klass)->get_property = _vala_boxes_toast_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_boxes_toast_set_property;
	G_OBJECT_CLASS (klass)->finalize = boxes_toast_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_TOAST_MESSAGE_PROPERTY, boxes_toast_properties[BOXES_TOAST_MESSAGE_PROPERTY] = g_param_spec_string ("message", "message", "message", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_TOAST_ACTION_PROPERTY, boxes_toast_properties[BOXES_TOAST_ACTION_PROPERTY] = g_param_spec_string ("action", "action", "action", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Boxes/ui/toast.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "label", FALSE, BoxesToast_private_offset + G_STRUCT_OFFSET (BoxesToastPrivate, label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "button", FALSE, BoxesToast_private_offset + G_STRUCT_OFFSET (BoxesToastPrivate, button));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_dismiss_button_clicked", G_CALLBACK(_boxes_toast_on_dismiss_button_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_undo_button_clicked", G_CALLBACK(_boxes_toast_on_undo_button_clicked_gtk_button_clicked));
}

static void
boxes_toast_instance_init (BoxesToast * self,
                           gpointer klass)
{
	self->priv = boxes_toast_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
boxes_toast_finalize (GObject * obj)
{
	BoxesToast * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_TOAST, BoxesToast);
	(self->undo_func_target_destroy_notify == NULL) ? NULL : (self->undo_func_target_destroy_notify (self->undo_func_target), NULL);
	self->undo_func = NULL;
	self->undo_func_target = NULL;
	self->undo_func_target_destroy_notify = NULL;
	(self->dismiss_func_target_destroy_notify == NULL) ? NULL : (self->dismiss_func_target_destroy_notify (self->dismiss_func_target), NULL);
	self->dismiss_func = NULL;
	self->dismiss_func_target = NULL;
	self->dismiss_func_target_destroy_notify = NULL;
	G_OBJECT_CLASS (boxes_toast_parent_class)->finalize (obj);
}

static GType
boxes_toast_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesToastClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_toast_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesToast), 0, (GInstanceInitFunc) boxes_toast_instance_init, NULL };
	GType boxes_toast_type_id;
	boxes_toast_type_id = g_type_register_static (gtk_box_get_type (), "BoxesToast", &g_define_type_info, 0);
	BoxesToast_private_offset = g_type_add_instance_private (boxes_toast_type_id, sizeof (BoxesToastPrivate));
	return boxes_toast_type_id;
}

GType
boxes_toast_get_type (void)
{
	static volatile gsize boxes_toast_type_id__once = 0;
	if (g_once_init_enter (&boxes_toast_type_id__once)) {
		GType boxes_toast_type_id;
		boxes_toast_type_id = boxes_toast_get_type_once ();
		g_once_init_leave (&boxes_toast_type_id__once, boxes_toast_type_id);
	}
	return boxes_toast_type_id__once;
}

static void
_vala_boxes_toast_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	BoxesToast * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_TOAST, BoxesToast);
	switch (property_id) {
		case BOXES_TOAST_MESSAGE_PROPERTY:
		g_value_set_string (value, boxes_toast_get_message (self));
		break;
		case BOXES_TOAST_ACTION_PROPERTY:
		g_value_set_string (value, boxes_toast_get_action (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_boxes_toast_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	BoxesToast * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_TOAST, BoxesToast);
	switch (property_id) {
		case BOXES_TOAST_MESSAGE_PROPERTY:
		boxes_toast_set_message (self, g_value_get_string (value));
		break;
		case BOXES_TOAST_ACTION_PROPERTY:
		boxes_toast_set_action (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

