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

/*
 * Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
 *
 * 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
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <float.h>
#include <math.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 DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD (dialogs_productivity_report_stat_card_get_type ())
#define DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD, DialogsProductivityReportStatCard))
#define DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD, DialogsProductivityReportStatCardClass))
#define DIALOGS_PRODUCTIVITY_REPORT_IS_STAT_CARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD))
#define DIALOGS_PRODUCTIVITY_REPORT_IS_STAT_CARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD))
#define DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD, DialogsProductivityReportStatCardClass))

typedef struct _DialogsProductivityReportStatCard DialogsProductivityReportStatCard;
typedef struct _DialogsProductivityReportStatCardClass DialogsProductivityReportStatCardClass;
typedef struct _DialogsProductivityReportStatCardPrivate DialogsProductivityReportStatCardPrivate;
enum  {
	DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_0_PROPERTY,
	DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_VALUE_PROPERTY,
	DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_LABEL_PROPERTY,
	DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_NUM_PROPERTIES
};
static GParamSpec* dialogs_productivity_report_stat_card_properties[DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _DialogsProductivityReportStatCard {
	AdwBin parent_instance;
	DialogsProductivityReportStatCardPrivate * priv;
};

struct _DialogsProductivityReportStatCardClass {
	AdwBinClass parent_class;
};

struct _DialogsProductivityReportStatCardPrivate {
	GtkLabel* _value_label;
	GtkLabel* _description_label;
	gchar* _stat_label;
};

static gint DialogsProductivityReportStatCard_private_offset;
static gpointer dialogs_productivity_report_stat_card_parent_class = NULL;

VALA_EXTERN GType dialogs_productivity_report_stat_card_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsProductivityReportStatCard, g_object_unref)
VALA_EXTERN DialogsProductivityReportStatCard* dialogs_productivity_report_stat_card_new (const gchar* stat_value,
                                                                              const gchar* stat_label);
VALA_EXTERN DialogsProductivityReportStatCard* dialogs_productivity_report_stat_card_construct (GType object_type,
                                                                                    const gchar* stat_value,
                                                                                    const gchar* stat_label);
VALA_EXTERN void dialogs_productivity_report_stat_card_set_stat_value (DialogsProductivityReportStatCard* self,
                                                           const gchar* value);
VALA_EXTERN void dialogs_productivity_report_stat_card_animate_to (DialogsProductivityReportStatCard* self,
                                                       gint target,
                                                       guint duration);
static void __lambda907_ (DialogsProductivityReportStatCard* self,
                   gdouble val);
static void ___lambda907__adw_animation_target_func (gdouble value,
                                              gpointer self);
VALA_EXTERN const gchar* dialogs_productivity_report_stat_card_get_stat_value (DialogsProductivityReportStatCard* self);
VALA_EXTERN const gchar* dialogs_productivity_report_stat_card_get_stat_label (DialogsProductivityReportStatCard* self);
static void dialogs_productivity_report_stat_card_set_stat_label (DialogsProductivityReportStatCard* self,
                                                           const gchar* value);
static GObject * dialogs_productivity_report_stat_card_constructor (GType type,
                                                             guint n_construct_properties,
                                                             GObjectConstructParam * construct_properties);
static void dialogs_productivity_report_stat_card_finalize (GObject * obj);
static GType dialogs_productivity_report_stat_card_get_type_once (void);
static void _vala_dialogs_productivity_report_stat_card_get_property (GObject * object,
                                                               guint property_id,
                                                               GValue * value,
                                                               GParamSpec * pspec);
static void _vala_dialogs_productivity_report_stat_card_set_property (GObject * object,
                                                               guint property_id,
                                                               const GValue * value,
                                                               GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
dialogs_productivity_report_stat_card_get_instance_private (DialogsProductivityReportStatCard* self)
{
	return G_STRUCT_MEMBER_P (self, DialogsProductivityReportStatCard_private_offset);
}

DialogsProductivityReportStatCard*
dialogs_productivity_report_stat_card_construct (GType object_type,
                                                 const gchar* stat_value,
                                                 const gchar* stat_label)
{
	DialogsProductivityReportStatCard * self = NULL;
	g_return_val_if_fail (stat_value != NULL, NULL);
	g_return_val_if_fail (stat_label != NULL, NULL);
	self = (DialogsProductivityReportStatCard*) g_object_new (object_type, "stat-label", stat_label, NULL);
	dialogs_productivity_report_stat_card_set_stat_value (self, stat_value);
	return self;
}

DialogsProductivityReportStatCard*
dialogs_productivity_report_stat_card_new (const gchar* stat_value,
                                           const gchar* stat_label)
{
	return dialogs_productivity_report_stat_card_construct (DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD, stat_value, stat_label);
}

static void
__lambda907_ (DialogsProductivityReportStatCard* self,
              gdouble val)
{
	GtkLabel* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	_tmp0_ = self->priv->_value_label;
	_tmp1_ = g_strdup_printf ("%i", (gint) round (val));
	_tmp2_ = _tmp1_;
	gtk_label_set_label (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
}

static void
___lambda907__adw_animation_target_func (gdouble value,
                                         gpointer self)
{
	__lambda907_ ((DialogsProductivityReportStatCard*) self, value);
}

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

void
dialogs_productivity_report_stat_card_animate_to (DialogsProductivityReportStatCard* self,
                                                  gint target,
                                                  guint duration)
{
	AdwCallbackAnimationTarget* animation_target = NULL;
	AdwCallbackAnimationTarget* _tmp0_;
	AdwTimedAnimation* animation = NULL;
	AdwAnimationTarget* _tmp1_;
	AdwTimedAnimation* _tmp2_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = (AdwCallbackAnimationTarget*) adw_callback_animation_target_new (___lambda907__adw_animation_target_func, g_object_ref (self), g_object_unref);
	animation_target = _tmp0_;
	_tmp1_ = _g_object_ref0 ((AdwAnimationTarget*) animation_target);
	_tmp2_ = (AdwTimedAnimation*) adw_timed_animation_new ((GtkWidget*) self, (gdouble) 0, (gdouble) target, duration, _tmp1_);
	adw_timed_animation_set_easing (_tmp2_, ADW_EASE_OUT_CUBIC);
	animation = _tmp2_;
	adw_animation_play ((AdwAnimation*) animation);
	_g_object_unref0 (animation);
	_g_object_unref0 (animation_target);
}

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

void
dialogs_productivity_report_stat_card_set_stat_value (DialogsProductivityReportStatCard* self,
                                                      const gchar* value)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_value_label;
	gtk_label_set_label (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, dialogs_productivity_report_stat_card_properties[DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_VALUE_PROPERTY]);
}

const gchar*
dialogs_productivity_report_stat_card_get_stat_label (DialogsProductivityReportStatCard* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_stat_label;
	result = _tmp0_;
	return result;
}

static void
dialogs_productivity_report_stat_card_set_stat_label (DialogsProductivityReportStatCard* self,
                                                      const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = dialogs_productivity_report_stat_card_get_stat_label (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_stat_label);
		self->priv->_stat_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dialogs_productivity_report_stat_card_properties[DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_LABEL_PROPERTY]);
	}
}

static GObject *
dialogs_productivity_report_stat_card_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DialogsProductivityReportStatCard * self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	GtkLabel* _tmp3_ = NULL;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp7_;
	GtkLabel* _tmp8_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp9_ = NULL;
	GtkBox* _tmp10_;
	GtkLabel* _tmp11_;
	GtkBox* _tmp12_;
	GtkLabel* _tmp13_;
	gchar* _tmp14_;
	gchar** _tmp15_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	GtkBox* _tmp17_;
	parent_class = G_OBJECT_CLASS (dialogs_productivity_report_stat_card_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD, DialogsProductivityReportStatCard);
	_tmp0_ = g_strdup ("font-bold");
	_tmp1_ = g_strdup ("title-1");
	_tmp2_ = g_new0 (gchar*, 2 + 1);
	_tmp2_[0] = _tmp0_;
	_tmp2_[1] = _tmp1_;
	_tmp3_ = (GtkLabel*) gtk_label_new ("0");
	gtk_widget_set_css_classes ((GtkWidget*) _tmp3_, _tmp2_);
	_tmp2_ = (_vala_array_free (_tmp2_, 2, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->_value_label);
	self->priv->_value_label = _tmp3_;
	_tmp4_ = self->priv->_stat_label;
	_tmp5_ = g_strdup ("caption");
	_tmp6_ = g_strdup ("dimmed");
	_tmp7_ = g_new0 (gchar*, 2 + 1);
	_tmp7_[0] = _tmp5_;
	_tmp7_[1] = _tmp6_;
	_tmp8_ = (GtkLabel*) gtk_label_new (_tmp4_);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp8_, _tmp7_);
	_tmp7_ = (_vala_array_free (_tmp7_, 2, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_halign ((GtkWidget*) _tmp8_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->_description_label);
	self->priv->_description_label = _tmp8_;
	_tmp9_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_FILL);
	gtk_widget_set_valign ((GtkWidget*) _tmp9_, GTK_ALIGN_CENTER);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp9_, 16);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp9_, 16);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp9_, 8);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp9_, 8);
	g_object_ref_sink (_tmp9_);
	box = _tmp9_;
	_tmp10_ = box;
	_tmp11_ = self->priv->_value_label;
	gtk_box_append (_tmp10_, (GtkWidget*) _tmp11_);
	_tmp12_ = box;
	_tmp13_ = self->priv->_description_label;
	gtk_box_append (_tmp12_, (GtkWidget*) _tmp13_);
	_tmp14_ = g_strdup ("card");
	_tmp15_ = g_new0 (gchar*, 1 + 1);
	_tmp15_[0] = _tmp14_;
	_tmp16_ = _tmp15_;
	_tmp16__length1 = 1;
	gtk_widget_set_css_classes ((GtkWidget*) self, _tmp16_);
	_tmp16_ = (_vala_array_free (_tmp16_, _tmp16__length1, (GDestroyNotify) g_free), NULL);
	_tmp17_ = box;
	adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp17_);
	_g_object_unref0 (box);
	return obj;
}

static void
dialogs_productivity_report_stat_card_class_init (DialogsProductivityReportStatCardClass * klass,
                                                  gpointer klass_data)
{
	dialogs_productivity_report_stat_card_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DialogsProductivityReportStatCard_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dialogs_productivity_report_stat_card_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dialogs_productivity_report_stat_card_set_property;
	G_OBJECT_CLASS (klass)->constructor = dialogs_productivity_report_stat_card_constructor;
	G_OBJECT_CLASS (klass)->finalize = dialogs_productivity_report_stat_card_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_VALUE_PROPERTY, dialogs_productivity_report_stat_card_properties[DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_VALUE_PROPERTY] = g_param_spec_string ("stat-value", "stat-value", "stat-value", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_LABEL_PROPERTY, dialogs_productivity_report_stat_card_properties[DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_LABEL_PROPERTY] = g_param_spec_string ("stat-label", "stat-label", "stat-label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
dialogs_productivity_report_stat_card_instance_init (DialogsProductivityReportStatCard * self,
                                                     gpointer klass)
{
	self->priv = dialogs_productivity_report_stat_card_get_instance_private (self);
}

static void
dialogs_productivity_report_stat_card_finalize (GObject * obj)
{
	DialogsProductivityReportStatCard * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD, DialogsProductivityReportStatCard);
	_g_object_unref0 (self->priv->_value_label);
	_g_object_unref0 (self->priv->_description_label);
	_g_free0 (self->priv->_stat_label);
	G_OBJECT_CLASS (dialogs_productivity_report_stat_card_parent_class)->finalize (obj);
}

static GType
dialogs_productivity_report_stat_card_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DialogsProductivityReportStatCardClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dialogs_productivity_report_stat_card_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DialogsProductivityReportStatCard), 0, (GInstanceInitFunc) dialogs_productivity_report_stat_card_instance_init, NULL };
	GType dialogs_productivity_report_stat_card_type_id;
	dialogs_productivity_report_stat_card_type_id = g_type_register_static (adw_bin_get_type (), "DialogsProductivityReportStatCard", &g_define_type_info, 0);
	DialogsProductivityReportStatCard_private_offset = g_type_add_instance_private (dialogs_productivity_report_stat_card_type_id, sizeof (DialogsProductivityReportStatCardPrivate));
	return dialogs_productivity_report_stat_card_type_id;
}

GType
dialogs_productivity_report_stat_card_get_type (void)
{
	static volatile gsize dialogs_productivity_report_stat_card_type_id__once = 0;
	if (g_once_init_enter (&dialogs_productivity_report_stat_card_type_id__once)) {
		GType dialogs_productivity_report_stat_card_type_id;
		dialogs_productivity_report_stat_card_type_id = dialogs_productivity_report_stat_card_get_type_once ();
		g_once_init_leave (&dialogs_productivity_report_stat_card_type_id__once, dialogs_productivity_report_stat_card_type_id);
	}
	return dialogs_productivity_report_stat_card_type_id__once;
}

static void
_vala_dialogs_productivity_report_stat_card_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec)
{
	DialogsProductivityReportStatCard * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD, DialogsProductivityReportStatCard);
	switch (property_id) {
		case DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_VALUE_PROPERTY:
		g_value_set_string (value, dialogs_productivity_report_stat_card_get_stat_value (self));
		break;
		case DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_LABEL_PROPERTY:
		g_value_set_string (value, dialogs_productivity_report_stat_card_get_stat_label (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dialogs_productivity_report_stat_card_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec)
{
	DialogsProductivityReportStatCard * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_PRODUCTIVITY_REPORT_TYPE_STAT_CARD, DialogsProductivityReportStatCard);
	switch (property_id) {
		case DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_VALUE_PROPERTY:
		dialogs_productivity_report_stat_card_set_stat_value (self, g_value_get_string (value));
		break;
		case DIALOGS_PRODUCTIVITY_REPORT_STAT_CARD_STAT_LABEL_PROPERTY:
		dialogs_productivity_report_stat_card_set_stat_label (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

