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

/*
* Copyright 2019 elementary, Inc. (https://elementary.io)
*
* 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <float.h>
#include <math.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
#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 NOTIFICATIONS_TYPE_ABSTRACT_BUBBLE (notifications_abstract_bubble_get_type ())
#define NOTIFICATIONS_ABSTRACT_BUBBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NOTIFICATIONS_TYPE_ABSTRACT_BUBBLE, NotificationsAbstractBubble))
#define NOTIFICATIONS_ABSTRACT_BUBBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NOTIFICATIONS_TYPE_ABSTRACT_BUBBLE, NotificationsAbstractBubbleClass))
#define NOTIFICATIONS_IS_ABSTRACT_BUBBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NOTIFICATIONS_TYPE_ABSTRACT_BUBBLE))
#define NOTIFICATIONS_IS_ABSTRACT_BUBBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NOTIFICATIONS_TYPE_ABSTRACT_BUBBLE))
#define NOTIFICATIONS_ABSTRACT_BUBBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NOTIFICATIONS_TYPE_ABSTRACT_BUBBLE, NotificationsAbstractBubbleClass))

typedef struct _NotificationsAbstractBubble NotificationsAbstractBubble;
typedef struct _NotificationsAbstractBubbleClass NotificationsAbstractBubbleClass;
typedef struct _NotificationsAbstractBubblePrivate NotificationsAbstractBubblePrivate;
typedef enum  {
	NOTIFICATIONS_CLOSE_REASON_EXPIRED = 1,
	NOTIFICATIONS_CLOSE_REASON_DISMISSED = 2,
	NOTIFICATIONS_CLOSE_REASON_CLOSE_NOTIFICATION_CALL = 3,
	NOTIFICATIONS_CLOSE_REASON_UNDEFINED = 4
} NotificationsCloseReason;

#define NOTIFICATIONS_TYPE_CLOSE_REASON (notifications_close_reason_get_type ())

#define NOTIFICATIONS_TYPE_CONFIRMATION (notifications_confirmation_get_type ())
#define NOTIFICATIONS_CONFIRMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NOTIFICATIONS_TYPE_CONFIRMATION, NotificationsConfirmation))
#define NOTIFICATIONS_CONFIRMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NOTIFICATIONS_TYPE_CONFIRMATION, NotificationsConfirmationClass))
#define NOTIFICATIONS_IS_CONFIRMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NOTIFICATIONS_TYPE_CONFIRMATION))
#define NOTIFICATIONS_IS_CONFIRMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NOTIFICATIONS_TYPE_CONFIRMATION))
#define NOTIFICATIONS_CONFIRMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NOTIFICATIONS_TYPE_CONFIRMATION, NotificationsConfirmationClass))

typedef struct _NotificationsConfirmation NotificationsConfirmation;
typedef struct _NotificationsConfirmationClass NotificationsConfirmationClass;
typedef struct _NotificationsConfirmationPrivate NotificationsConfirmationPrivate;
enum  {
	NOTIFICATIONS_CONFIRMATION_0_PROPERTY,
	NOTIFICATIONS_CONFIRMATION_ICON_NAME_PROPERTY,
	NOTIFICATIONS_CONFIRMATION_PROGRESS_PROPERTY,
	NOTIFICATIONS_CONFIRMATION_NUM_PROPERTIES
};
static GParamSpec* notifications_confirmation_properties[NOTIFICATIONS_CONFIRMATION_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 _NotificationsAbstractBubble {
	GtkWindow parent_instance;
	NotificationsAbstractBubblePrivate * priv;
	GtkStack* content_area;
};

struct _NotificationsAbstractBubbleClass {
	GtkWindowClass parent_class;
};

struct _NotificationsConfirmation {
	NotificationsAbstractBubble parent_instance;
	NotificationsConfirmationPrivate * priv;
};

struct _NotificationsConfirmationClass {
	NotificationsAbstractBubbleClass parent_class;
};

struct _NotificationsConfirmationPrivate {
	gchar* _icon_name;
	gdouble _progress;
};

static gint NotificationsConfirmation_private_offset;
static gpointer notifications_confirmation_parent_class = NULL;

VALA_EXTERN GType notifications_abstract_bubble_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NotificationsAbstractBubble, g_object_unref)
VALA_EXTERN GType notifications_close_reason_get_type (void) G_GNUC_CONST ;
static void notifications_abstract_bubble_closed (NotificationsAbstractBubble* self,
                                           NotificationsCloseReason reason);
VALA_EXTERN GType notifications_confirmation_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NotificationsConfirmation, g_object_unref)
VALA_EXTERN NotificationsConfirmation* notifications_confirmation_new (const gchar* icon_name,
                                                           gdouble progress);
VALA_EXTERN NotificationsConfirmation* notifications_confirmation_construct (GType object_type,
                                                                 const gchar* icon_name,
                                                                 gdouble progress);
VALA_EXTERN const gchar* notifications_confirmation_get_icon_name (NotificationsConfirmation* self);
VALA_EXTERN void notifications_confirmation_set_icon_name (NotificationsConfirmation* self,
                                               const gchar* value);
VALA_EXTERN gdouble notifications_confirmation_get_progress (NotificationsConfirmation* self);
VALA_EXTERN void notifications_confirmation_set_progress (NotificationsConfirmation* self,
                                              gdouble value);
static GObject * notifications_confirmation_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static void notifications_confirmation_finalize (GObject * obj);
static GType notifications_confirmation_get_type_once (void);
static void _vala_notifications_confirmation_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_notifications_confirmation_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);

static inline gpointer
notifications_confirmation_get_instance_private (NotificationsConfirmation* self)
{
	return G_STRUCT_MEMBER_P (self, NotificationsConfirmation_private_offset);
}

NotificationsConfirmation*
notifications_confirmation_construct (GType object_type,
                                      const gchar* icon_name,
                                      gdouble progress)
{
	NotificationsConfirmation * self = NULL;
	g_return_val_if_fail (icon_name != NULL, NULL);
	self = (NotificationsConfirmation*) g_object_new (object_type, "icon-name", icon_name, "progress", progress, "timeout", 2000, NULL);
	return self;
}

NotificationsConfirmation*
notifications_confirmation_new (const gchar* icon_name,
                                gdouble progress)
{
	return notifications_confirmation_construct (NOTIFICATIONS_TYPE_CONFIRMATION, icon_name, progress);
}

const gchar*
notifications_confirmation_get_icon_name (NotificationsConfirmation* 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
notifications_confirmation_set_icon_name (NotificationsConfirmation* self,
                                          const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = notifications_confirmation_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, notifications_confirmation_properties[NOTIFICATIONS_CONFIRMATION_ICON_NAME_PROPERTY]);
	}
}

gdouble
notifications_confirmation_get_progress (NotificationsConfirmation* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	result = self->priv->_progress;
	return result;
}

void
notifications_confirmation_set_progress (NotificationsConfirmation* self,
                                         gdouble value)
{
	gdouble old_value;
	g_return_if_fail (self != NULL);
	old_value = notifications_confirmation_get_progress (self);
	if (old_value != value) {
		self->priv->_progress = value;
		g_object_notify_by_pspec ((GObject *) self, notifications_confirmation_properties[NOTIFICATIONS_CONFIRMATION_PROGRESS_PROPERTY]);
	}
}

static GObject *
notifications_confirmation_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	NotificationsConfirmation * self;
	GtkImage* image = NULL;
	const gchar* _tmp0_;
	GtkImage* _tmp1_ = NULL;
	GtkProgressBar* progressbar = NULL;
	GtkProgressBar* _tmp2_ = NULL;
	GtkProgressBar* _tmp3_;
	GtkBox* contents = NULL;
	GtkBox* _tmp4_;
	GtkBox* _tmp5_;
	GtkImage* _tmp6_;
	GtkBox* _tmp7_;
	GtkProgressBar* _tmp8_;
	GtkStack* _tmp9_;
	GtkBox* _tmp10_;
	GtkImage* _tmp11_;
	GtkProgressBar* _tmp12_;
	parent_class = G_OBJECT_CLASS (notifications_confirmation_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTIFICATIONS_TYPE_CONFIRMATION, NotificationsConfirmation);
	_tmp0_ = self->priv->_icon_name;
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name (_tmp0_);
	gtk_widget_set_valign ((GtkWidget*) _tmp1_, GTK_ALIGN_START);
	gtk_image_set_pixel_size (_tmp1_, 48);
	g_object_ref_sink (_tmp1_);
	image = _tmp1_;
	_tmp2_ = (GtkProgressBar*) gtk_progress_bar_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp2_, TRUE);
	gtk_widget_set_valign ((GtkWidget*) _tmp2_, GTK_ALIGN_CENTER);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp2_, 6);
	g_object_set ((GtkWidget*) _tmp2_, "width-request", 258, NULL);
	g_object_ref_sink (_tmp2_);
	progressbar = _tmp2_;
	_tmp3_ = progressbar;
	gtk_widget_add_css_class ((GtkWidget*) _tmp3_, GRANITE_STYLE_CLASS_FLAT);
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp4_);
	contents = _tmp4_;
	_tmp5_ = contents;
	_tmp6_ = image;
	gtk_box_append (_tmp5_, (GtkWidget*) _tmp6_);
	_tmp7_ = contents;
	_tmp8_ = progressbar;
	gtk_box_append (_tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = ((NotificationsAbstractBubble*) self)->content_area;
	_tmp10_ = contents;
	gtk_stack_add_child (_tmp9_, (GtkWidget*) _tmp10_);
	gtk_widget_add_css_class ((GtkWidget*) self, "confirmation");
	_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)));
	_tmp12_ = progressbar;
	g_object_bind_property_with_closures ((GObject*) self, "progress", (GObject*) _tmp12_, "fraction", G_BINDING_SYNC_CREATE, (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 (contents);
	_g_object_unref0 (progressbar);
	_g_object_unref0 (image);
	return obj;
}

static void
notifications_confirmation_class_init (NotificationsConfirmationClass * klass,
                                       gpointer klass_data)
{
	notifications_confirmation_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NotificationsConfirmation_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_notifications_confirmation_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_notifications_confirmation_set_property;
	G_OBJECT_CLASS (klass)->constructor = notifications_confirmation_constructor;
	G_OBJECT_CLASS (klass)->finalize = notifications_confirmation_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), NOTIFICATIONS_CONFIRMATION_ICON_NAME_PROPERTY, notifications_confirmation_properties[NOTIFICATIONS_CONFIRMATION_ICON_NAME_PROPERTY] = g_param_spec_string ("icon-name", "icon-name", "icon-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), NOTIFICATIONS_CONFIRMATION_PROGRESS_PROPERTY, notifications_confirmation_properties[NOTIFICATIONS_CONFIRMATION_PROGRESS_PROPERTY] = g_param_spec_double ("progress", "progress", "progress", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
notifications_confirmation_instance_init (NotificationsConfirmation * self,
                                          gpointer klass)
{
	self->priv = notifications_confirmation_get_instance_private (self);
}

static void
notifications_confirmation_finalize (GObject * obj)
{
	NotificationsConfirmation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTIFICATIONS_TYPE_CONFIRMATION, NotificationsConfirmation);
	_g_free0 (self->priv->_icon_name);
	G_OBJECT_CLASS (notifications_confirmation_parent_class)->finalize (obj);
}

static GType
notifications_confirmation_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NotificationsConfirmationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) notifications_confirmation_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NotificationsConfirmation), 0, (GInstanceInitFunc) notifications_confirmation_instance_init, NULL };
	GType notifications_confirmation_type_id;
	notifications_confirmation_type_id = g_type_register_static (NOTIFICATIONS_TYPE_ABSTRACT_BUBBLE, "NotificationsConfirmation", &g_define_type_info, 0);
	NotificationsConfirmation_private_offset = g_type_add_instance_private (notifications_confirmation_type_id, sizeof (NotificationsConfirmationPrivate));
	return notifications_confirmation_type_id;
}

GType
notifications_confirmation_get_type (void)
{
	static volatile gsize notifications_confirmation_type_id__once = 0;
	if (g_once_init_enter (&notifications_confirmation_type_id__once)) {
		GType notifications_confirmation_type_id;
		notifications_confirmation_type_id = notifications_confirmation_get_type_once ();
		g_once_init_leave (&notifications_confirmation_type_id__once, notifications_confirmation_type_id);
	}
	return notifications_confirmation_type_id__once;
}

static void
_vala_notifications_confirmation_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	NotificationsConfirmation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NOTIFICATIONS_TYPE_CONFIRMATION, NotificationsConfirmation);
	switch (property_id) {
		case NOTIFICATIONS_CONFIRMATION_ICON_NAME_PROPERTY:
		g_value_set_string (value, notifications_confirmation_get_icon_name (self));
		break;
		case NOTIFICATIONS_CONFIRMATION_PROGRESS_PROPERTY:
		g_value_set_double (value, notifications_confirmation_get_progress (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_notifications_confirmation_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	NotificationsConfirmation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NOTIFICATIONS_TYPE_CONFIRMATION, NotificationsConfirmation);
	switch (property_id) {
		case NOTIFICATIONS_CONFIRMATION_ICON_NAME_PROPERTY:
		notifications_confirmation_set_icon_name (self, g_value_get_string (value));
		break;
		case NOTIFICATIONS_CONFIRMATION_PROGRESS_PROPERTY:
		notifications_confirmation_set_progress (self, g_value_get_double (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

