/* SummarySection.c generated by valac 0.56.19, the Vala compiler
 * generated from SummarySection.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 <glib.h>
#include <gee.h>
#include "planify.h"
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.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_SUMMARY_SECTION (dialogs_productivity_report_summary_section_get_type ())
#define DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_PRODUCTIVITY_REPORT_TYPE_SUMMARY_SECTION, DialogsProductivityReportSummarySection))
#define DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_PRODUCTIVITY_REPORT_TYPE_SUMMARY_SECTION, DialogsProductivityReportSummarySectionClass))
#define DIALOGS_PRODUCTIVITY_REPORT_IS_SUMMARY_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_PRODUCTIVITY_REPORT_TYPE_SUMMARY_SECTION))
#define DIALOGS_PRODUCTIVITY_REPORT_IS_SUMMARY_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_PRODUCTIVITY_REPORT_TYPE_SUMMARY_SECTION))
#define DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_PRODUCTIVITY_REPORT_TYPE_SUMMARY_SECTION, DialogsProductivityReportSummarySectionClass))

typedef struct _DialogsProductivityReportSummarySection DialogsProductivityReportSummarySection;
typedef struct _DialogsProductivityReportSummarySectionClass DialogsProductivityReportSummarySectionClass;
typedef struct _DialogsProductivityReportSummarySectionPrivate DialogsProductivityReportSummarySectionPrivate;

#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;
enum  {
	DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_0_PROPERTY,
	DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_NUM_PROPERTIES
};
static GParamSpec* dialogs_productivity_report_summary_section_properties[DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_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))
enum  {
	DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_SEE_MORE_CLICKED_SIGNAL,
	DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_NUM_SIGNALS
};
static guint dialogs_productivity_report_summary_section_signals[DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_NUM_SIGNALS] = {0};

struct _DialogsProductivityReportSummarySection {
	AdwBin parent_instance;
	DialogsProductivityReportSummarySectionPrivate * priv;
};

struct _DialogsProductivityReportSummarySectionClass {
	AdwBinClass parent_class;
};

struct _DialogsProductivityReportSummarySectionPrivate {
	DialogsProductivityReportStatCard* total_card;
	DialogsProductivityReportStatCard* pending_card;
	DialogsProductivityReportStatCard* completed_card;
	DialogsProductivityReportStatCard* overdue_card;
	GtkLabel* progress_value_label;
	GtkLevelBar* progress_bar;
};

static gint DialogsProductivityReportSummarySection_private_offset;
static gpointer dialogs_productivity_report_summary_section_parent_class = NULL;

VALA_EXTERN GType dialogs_productivity_report_summary_section_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsProductivityReportSummarySection, g_object_unref)
VALA_EXTERN GType dialogs_productivity_report_stat_card_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsProductivityReportStatCard, g_object_unref)
static void dialogs_productivity_report_summary_section_load_stats (DialogsProductivityReportSummarySection* self);
VALA_EXTERN void dialogs_productivity_report_stat_card_animate_to (DialogsProductivityReportStatCard* self,
                                                       gint target,
                                                       guint duration);
static void __lambda921_ (DialogsProductivityReportSummarySection* self,
                   gdouble val);
static void ___lambda921__adw_animation_target_func (gdouble value,
                                              gpointer self);
VALA_EXTERN DialogsProductivityReportSummarySection* dialogs_productivity_report_summary_section_new (void);
VALA_EXTERN DialogsProductivityReportSummarySection* dialogs_productivity_report_summary_section_construct (GType object_type);
static GObject * dialogs_productivity_report_summary_section_constructor (GType type,
                                                                   guint n_construct_properties,
                                                                   GObjectConstructParam * construct_properties);
static void _dialogs_productivity_report_summary_section___lambda922_ (DialogsProductivityReportSummarySection* self);
static void __dialogs_productivity_report_summary_section___lambda922__gtk_button_clicked (GtkButton* _sender,
                                                                                    gpointer self);
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);
static void _dialogs_productivity_report_summary_section___lambda923_ (DialogsProductivityReportSummarySection* self);
static gboolean __lambda924_ (DialogsProductivityReportSummarySection* self);
static gboolean ___lambda924__gsource_func (gpointer self);
static void __dialogs_productivity_report_summary_section___lambda923__gtk_widget_map (GtkWidget* _sender,
                                                                                gpointer self);
static void dialogs_productivity_report_summary_section_finalize (GObject * obj);
static GType dialogs_productivity_report_summary_section_get_type_once (void);
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_summary_section_get_instance_private (DialogsProductivityReportSummarySection* self)
{
	return G_STRUCT_MEMBER_P (self, DialogsProductivityReportSummarySection_private_offset);
}

static void
__lambda921_ (DialogsProductivityReportSummarySection* self,
              gdouble val)
{
	GtkLevelBar* _tmp0_;
	GtkLabel* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = self->priv->progress_bar;
	gtk_level_bar_set_value (_tmp0_, val);
	_tmp1_ = self->priv->progress_value_label;
	_tmp2_ = g_strdup_printf ("%d%%", (gint) round (val * 100));
	_tmp3_ = _tmp2_;
	gtk_label_set_label (_tmp1_, _tmp3_);
	_g_free0 (_tmp3_);
}

static void
___lambda921__adw_animation_target_func (gdouble value,
                                         gpointer self)
{
	__lambda921_ ((DialogsProductivityReportSummarySection*) self, value);
}

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

static void
dialogs_productivity_report_summary_section_load_stats (DialogsProductivityReportSummarySection* self)
{
	gint total = 0;
	gint pending = 0;
	gint completed = 0;
	gint overdue = 0;
	ServicesStore* _tmp17_;
	GeeArrayList* _tmp18_;
	GeeArrayList* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	gint _tmp22_;
	gdouble _tmp23_ = 0.0;
	gdouble progress = 0.0;
	DialogsProductivityReportStatCard* _tmp24_;
	DialogsProductivityReportStatCard* _tmp25_;
	DialogsProductivityReportStatCard* _tmp26_;
	DialogsProductivityReportStatCard* _tmp27_;
	AdwCallbackAnimationTarget* progress_target = NULL;
	AdwCallbackAnimationTarget* _tmp28_;
	AdwTimedAnimation* progress_animation = NULL;
	GtkLevelBar* _tmp29_;
	AdwAnimationTarget* _tmp30_;
	AdwTimedAnimation* _tmp31_ = NULL;
	g_return_if_fail (self != NULL);
	total = 0;
	pending = 0;
	completed = 0;
	{
		GeeArrayList* _item_list = NULL;
		ServicesStore* _tmp0_;
		GeeArrayList* _tmp1_;
		GeeArrayList* _tmp2_;
		gint _item_size = 0;
		GeeArrayList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _item_index = 0;
		_tmp0_ = services_store_instance ();
		_tmp1_ = services_store_get_items (_tmp0_);
		_tmp2_ = _tmp1_;
		_item_list = _tmp2_;
		_tmp3_ = _item_list;
		_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_item_size = _tmp5_;
		_item_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			ObjectsItem* item = NULL;
			GeeArrayList* _tmp8_;
			gpointer _tmp9_;
			ObjectsItem* _tmp10_;
			gint _tmp11_;
			ObjectsItem* _tmp12_;
			gboolean _tmp13_;
			gboolean _tmp14_;
			_item_index = _item_index + 1;
			_tmp6_ = _item_index;
			_tmp7_ = _item_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _item_list;
			_tmp9_ = gee_abstract_list_get ((GeeAbstractList*) _tmp8_, _item_index);
			item = (ObjectsItem*) _tmp9_;
			_tmp10_ = item;
			if (objects_item_was_archived (_tmp10_)) {
				_g_object_unref0 (item);
				continue;
			}
			_tmp11_ = total;
			total = _tmp11_ + 1;
			_tmp12_ = item;
			_tmp13_ = objects_item_get_checked (_tmp12_);
			_tmp14_ = _tmp13_;
			if (_tmp14_) {
				gint _tmp15_;
				_tmp15_ = completed;
				completed = _tmp15_ + 1;
			} else {
				gint _tmp16_;
				_tmp16_ = pending;
				pending = _tmp16_ + 1;
			}
			_g_object_unref0 (item);
		}
	}
	_tmp17_ = services_store_instance ();
	_tmp18_ = services_store_get_items_by_overdue_view (_tmp17_, FALSE);
	_tmp19_ = _tmp18_;
	_tmp20_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = _tmp21_;
	_g_object_unref0 (_tmp19_);
	overdue = _tmp22_;
	if (total > 0) {
		_tmp23_ = ((gdouble) completed) / ((gdouble) total);
	} else {
		_tmp23_ = 0.0;
	}
	progress = _tmp23_;
	_tmp24_ = self->priv->total_card;
	dialogs_productivity_report_stat_card_animate_to (_tmp24_, total, (guint) 600);
	_tmp25_ = self->priv->pending_card;
	dialogs_productivity_report_stat_card_animate_to (_tmp25_, pending, (guint) 600);
	_tmp26_ = self->priv->completed_card;
	dialogs_productivity_report_stat_card_animate_to (_tmp26_, completed, (guint) 600);
	_tmp27_ = self->priv->overdue_card;
	dialogs_productivity_report_stat_card_animate_to (_tmp27_, overdue, (guint) 600);
	_tmp28_ = (AdwCallbackAnimationTarget*) adw_callback_animation_target_new (___lambda921__adw_animation_target_func, g_object_ref (self), g_object_unref);
	progress_target = _tmp28_;
	_tmp29_ = self->priv->progress_bar;
	_tmp30_ = _g_object_ref0 ((AdwAnimationTarget*) progress_target);
	_tmp31_ = (AdwTimedAnimation*) adw_timed_animation_new ((GtkWidget*) _tmp29_, (gdouble) 0, progress, (guint) 800, _tmp30_);
	adw_timed_animation_set_easing (_tmp31_, ADW_EASE_OUT_CUBIC);
	progress_animation = _tmp31_;
	adw_animation_play ((AdwAnimation*) progress_animation);
	_g_object_unref0 (progress_animation);
	_g_object_unref0 (progress_target);
}

DialogsProductivityReportSummarySection*
dialogs_productivity_report_summary_section_construct (GType object_type)
{
	DialogsProductivityReportSummarySection * self = NULL;
	self = (DialogsProductivityReportSummarySection*) g_object_new (object_type, NULL);
	return self;
}

DialogsProductivityReportSummarySection*
dialogs_productivity_report_summary_section_new (void)
{
	return dialogs_productivity_report_summary_section_construct (DIALOGS_PRODUCTIVITY_REPORT_TYPE_SUMMARY_SECTION);
}

static void
_dialogs_productivity_report_summary_section___lambda922_ (DialogsProductivityReportSummarySection* self)
{
	g_signal_emit (self, dialogs_productivity_report_summary_section_signals[DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_SEE_MORE_CLICKED_SIGNAL], 0);
}

static void
__dialogs_productivity_report_summary_section___lambda922__gtk_button_clicked (GtkButton* _sender,
                                                                               gpointer self)
{
	_dialogs_productivity_report_summary_section___lambda922_ ((DialogsProductivityReportSummarySection*) self);
}

static gboolean
__lambda924_ (DialogsProductivityReportSummarySection* self)
{
	gboolean result;
	dialogs_productivity_report_summary_section_load_stats (self);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda924__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda924_ ((DialogsProductivityReportSummarySection*) self);
	return result;
}

static void
_dialogs_productivity_report_summary_section___lambda923_ (DialogsProductivityReportSummarySection* self)
{
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 200, ___lambda924__gsource_func, g_object_ref (self), g_object_unref);
}

static void
__dialogs_productivity_report_summary_section___lambda923__gtk_widget_map (GtkWidget* _sender,
                                                                           gpointer self)
{
	_dialogs_productivity_report_summary_section___lambda923_ ((DialogsProductivityReportSummarySection*) self);
}

static GObject *
dialogs_productivity_report_summary_section_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DialogsProductivityReportSummarySection * self;
	GtkLabel* title_label = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	GtkLabel* _tmp2_ = NULL;
	GtkButton* see_more_button = NULL;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	GtkButton* _tmp6_ = NULL;
	GtkButton* _tmp7_;
	GtkBox* header_box = NULL;
	GtkBox* _tmp8_ = NULL;
	GtkBox* _tmp9_;
	GtkLabel* _tmp10_;
	GtkBox* _tmp11_;
	GtkButton* _tmp12_;
	DialogsProductivityReportStatCard* _tmp13_;
	DialogsProductivityReportStatCard* _tmp14_;
	DialogsProductivityReportStatCard* _tmp15_;
	DialogsProductivityReportStatCard* _tmp16_;
	GtkGrid* cards_grid = NULL;
	GtkGrid* _tmp17_ = NULL;
	GtkGrid* _tmp18_;
	DialogsProductivityReportStatCard* _tmp19_;
	GtkGrid* _tmp20_;
	DialogsProductivityReportStatCard* _tmp21_;
	GtkGrid* _tmp22_;
	DialogsProductivityReportStatCard* _tmp23_;
	GtkGrid* _tmp24_;
	DialogsProductivityReportStatCard* _tmp25_;
	GtkLabel* progress_label = NULL;
	gchar* _tmp26_;
	gchar** _tmp27_;
	GtkLabel* _tmp28_ = NULL;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar** _tmp31_;
	GtkLabel* _tmp32_ = NULL;
	GtkBox* progress_header = NULL;
	GtkBox* _tmp33_;
	GtkBox* _tmp34_;
	GtkLabel* _tmp35_;
	GtkBox* _tmp36_;
	GtkLabel* _tmp37_;
	GtkLevelBar* _tmp38_ = NULL;
	GtkBox* progress_content = NULL;
	GtkBox* _tmp39_ = NULL;
	GtkBox* _tmp40_;
	GtkBox* _tmp41_;
	GtkBox* _tmp42_;
	GtkLevelBar* _tmp43_;
	AdwBin* progress_card = NULL;
	gchar* _tmp44_;
	gchar** _tmp45_;
	GtkBox* _tmp46_;
	GtkWidget* _tmp47_;
	AdwBin* _tmp48_ = NULL;
	GtkBox* section_box = NULL;
	GtkBox* _tmp49_;
	GtkBox* _tmp50_;
	GtkBox* _tmp51_;
	GtkBox* _tmp52_;
	GtkGrid* _tmp53_;
	GtkBox* _tmp54_;
	AdwBin* _tmp55_;
	GtkBox* _tmp56_;
	parent_class = G_OBJECT_CLASS (dialogs_productivity_report_summary_section_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_PRODUCTIVITY_REPORT_TYPE_SUMMARY_SECTION, DialogsProductivityReportSummarySection);
	_tmp0_ = g_strdup ("font-bold");
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	_tmp2_ = (GtkLabel*) gtk_label_new (_ ("Summary"));
	gtk_widget_set_halign ((GtkWidget*) _tmp2_, GTK_ALIGN_START);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp2_, _tmp1_);
	_tmp1_ = (_vala_array_free (_tmp1_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp2_);
	title_label = _tmp2_;
	_tmp3_ = g_strdup ("flat");
	_tmp4_ = g_strdup ("caption");
	_tmp5_ = g_new0 (gchar*, 2 + 1);
	_tmp5_[0] = _tmp3_;
	_tmp5_[1] = _tmp4_;
	_tmp6_ = (GtkButton*) gtk_button_new_with_label (_ ("See More"));
	gtk_widget_set_halign ((GtkWidget*) _tmp6_, GTK_ALIGN_END);
	gtk_widget_set_valign ((GtkWidget*) _tmp6_, GTK_ALIGN_CENTER);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp6_, TRUE);
	gtk_widget_set_visible ((GtkWidget*) _tmp6_, FALSE);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp6_, _tmp5_);
	_tmp5_ = (_vala_array_free (_tmp5_, 2, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp6_);
	see_more_button = _tmp6_;
	_tmp7_ = see_more_button;
	g_signal_connect_object (_tmp7_, "clicked", (GCallback) __dialogs_productivity_report_summary_section___lambda922__gtk_button_clicked, self, 0);
	_tmp8_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp8_, TRUE);
	g_object_ref_sink (_tmp8_);
	header_box = _tmp8_;
	_tmp9_ = header_box;
	_tmp10_ = title_label;
	gtk_box_append (_tmp9_, (GtkWidget*) _tmp10_);
	_tmp11_ = header_box;
	_tmp12_ = see_more_button;
	gtk_box_append (_tmp11_, (GtkWidget*) _tmp12_);
	_tmp13_ = dialogs_productivity_report_stat_card_new ("0", _ ("Total"));
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->total_card);
	self->priv->total_card = _tmp13_;
	_tmp14_ = dialogs_productivity_report_stat_card_new ("0", _ ("Pending"));
	g_object_ref_sink (_tmp14_);
	_g_object_unref0 (self->priv->pending_card);
	self->priv->pending_card = _tmp14_;
	_tmp15_ = dialogs_productivity_report_stat_card_new ("0", _ ("Completed"));
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->completed_card);
	self->priv->completed_card = _tmp15_;
	_tmp16_ = dialogs_productivity_report_stat_card_new ("0", _ ("Overdue"));
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->overdue_card);
	self->priv->overdue_card = _tmp16_;
	_tmp17_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_column_spacing (_tmp17_, 12);
	gtk_grid_set_row_spacing (_tmp17_, 12);
	gtk_grid_set_column_homogeneous (_tmp17_, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp17_, TRUE);
	g_object_ref_sink (_tmp17_);
	cards_grid = _tmp17_;
	_tmp18_ = cards_grid;
	_tmp19_ = self->priv->total_card;
	gtk_grid_attach (_tmp18_, (GtkWidget*) _tmp19_, 0, 0, 1, 1);
	_tmp20_ = cards_grid;
	_tmp21_ = self->priv->pending_card;
	gtk_grid_attach (_tmp20_, (GtkWidget*) _tmp21_, 1, 0, 1, 1);
	_tmp22_ = cards_grid;
	_tmp23_ = self->priv->completed_card;
	gtk_grid_attach (_tmp22_, (GtkWidget*) _tmp23_, 2, 0, 1, 1);
	_tmp24_ = cards_grid;
	_tmp25_ = self->priv->overdue_card;
	gtk_grid_attach (_tmp24_, (GtkWidget*) _tmp25_, 3, 0, 1, 1);
	_tmp26_ = g_strdup ("caption");
	_tmp27_ = g_new0 (gchar*, 1 + 1);
	_tmp27_[0] = _tmp26_;
	_tmp28_ = (GtkLabel*) gtk_label_new (_ ("Progress"));
	gtk_widget_set_halign ((GtkWidget*) _tmp28_, GTK_ALIGN_START);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp28_, _tmp27_);
	_tmp27_ = (_vala_array_free (_tmp27_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp28_);
	progress_label = _tmp28_;
	_tmp29_ = g_strdup ("caption");
	_tmp30_ = g_strdup ("dimmed");
	_tmp31_ = g_new0 (gchar*, 2 + 1);
	_tmp31_[0] = _tmp29_;
	_tmp31_[1] = _tmp30_;
	_tmp32_ = (GtkLabel*) gtk_label_new ("0%");
	gtk_widget_set_halign ((GtkWidget*) _tmp32_, GTK_ALIGN_END);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp32_, TRUE);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp32_, _tmp31_);
	_tmp31_ = (_vala_array_free (_tmp31_, 2, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp32_);
	_g_object_unref0 (self->priv->progress_value_label);
	self->priv->progress_value_label = _tmp32_;
	_tmp33_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp33_);
	progress_header = _tmp33_;
	_tmp34_ = progress_header;
	_tmp35_ = progress_label;
	gtk_box_append (_tmp34_, (GtkWidget*) _tmp35_);
	_tmp36_ = progress_header;
	_tmp37_ = self->priv->progress_value_label;
	gtk_box_append (_tmp36_, (GtkWidget*) _tmp37_);
	_tmp38_ = (GtkLevelBar*) gtk_level_bar_new ();
	gtk_level_bar_set_min_value (_tmp38_, 0.0);
	gtk_level_bar_set_max_value (_tmp38_, 1.0);
	gtk_level_bar_set_value (_tmp38_, 0.0);
	g_object_ref_sink (_tmp38_);
	_g_object_unref0 (self->priv->progress_bar);
	self->priv->progress_bar = _tmp38_;
	_tmp39_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp39_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp39_, 12);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp39_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp39_, 12);
	g_object_ref_sink (_tmp39_);
	progress_content = _tmp39_;
	_tmp40_ = progress_content;
	_tmp41_ = progress_header;
	gtk_box_append (_tmp40_, (GtkWidget*) _tmp41_);
	_tmp42_ = progress_content;
	_tmp43_ = self->priv->progress_bar;
	gtk_box_append (_tmp42_, (GtkWidget*) _tmp43_);
	_tmp44_ = g_strdup ("card");
	_tmp45_ = g_new0 (gchar*, 1 + 1);
	_tmp45_[0] = _tmp44_;
	_tmp46_ = progress_content;
	_tmp47_ = _g_object_ref0 ((GtkWidget*) _tmp46_);
	_tmp48_ = (AdwBin*) adw_bin_new ();
	gtk_widget_set_css_classes ((GtkWidget*) _tmp48_, _tmp45_);
	_tmp45_ = (_vala_array_free (_tmp45_, 1, (GDestroyNotify) g_free), NULL);
	adw_bin_set_child (_tmp48_, _tmp47_);
	_g_object_unref0 (_tmp47_);
	g_object_ref_sink (_tmp48_);
	progress_card = _tmp48_;
	_tmp49_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp49_);
	section_box = _tmp49_;
	_tmp50_ = section_box;
	_tmp51_ = header_box;
	gtk_box_append (_tmp50_, (GtkWidget*) _tmp51_);
	_tmp52_ = section_box;
	_tmp53_ = cards_grid;
	gtk_box_append (_tmp52_, (GtkWidget*) _tmp53_);
	_tmp54_ = section_box;
	_tmp55_ = progress_card;
	gtk_box_append (_tmp54_, (GtkWidget*) _tmp55_);
	_tmp56_ = section_box;
	adw_bin_set_child ((AdwBin*) self, (GtkWidget*) _tmp56_);
	g_signal_connect_object ((GtkWidget*) self, "map", (GCallback) __dialogs_productivity_report_summary_section___lambda923__gtk_widget_map, self, 0);
	_g_object_unref0 (section_box);
	_g_object_unref0 (progress_card);
	_g_object_unref0 (progress_content);
	_g_object_unref0 (progress_header);
	_g_object_unref0 (progress_label);
	_g_object_unref0 (cards_grid);
	_g_object_unref0 (header_box);
	_g_object_unref0 (see_more_button);
	_g_object_unref0 (title_label);
	return obj;
}

static void
dialogs_productivity_report_summary_section_class_init (DialogsProductivityReportSummarySectionClass * klass,
                                                        gpointer klass_data)
{
	dialogs_productivity_report_summary_section_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DialogsProductivityReportSummarySection_private_offset);
	G_OBJECT_CLASS (klass)->constructor = dialogs_productivity_report_summary_section_constructor;
	G_OBJECT_CLASS (klass)->finalize = dialogs_productivity_report_summary_section_finalize;
	dialogs_productivity_report_summary_section_signals[DIALOGS_PRODUCTIVITY_REPORT_SUMMARY_SECTION_SEE_MORE_CLICKED_SIGNAL] = g_signal_new ("see-more-clicked", DIALOGS_PRODUCTIVITY_REPORT_TYPE_SUMMARY_SECTION, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
dialogs_productivity_report_summary_section_instance_init (DialogsProductivityReportSummarySection * self,
                                                           gpointer klass)
{
	self->priv = dialogs_productivity_report_summary_section_get_instance_private (self);
}

static void
dialogs_productivity_report_summary_section_finalize (GObject * obj)
{
	DialogsProductivityReportSummarySection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_PRODUCTIVITY_REPORT_TYPE_SUMMARY_SECTION, DialogsProductivityReportSummarySection);
	_g_object_unref0 (self->priv->total_card);
	_g_object_unref0 (self->priv->pending_card);
	_g_object_unref0 (self->priv->completed_card);
	_g_object_unref0 (self->priv->overdue_card);
	_g_object_unref0 (self->priv->progress_value_label);
	_g_object_unref0 (self->priv->progress_bar);
	G_OBJECT_CLASS (dialogs_productivity_report_summary_section_parent_class)->finalize (obj);
}

static GType
dialogs_productivity_report_summary_section_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DialogsProductivityReportSummarySectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dialogs_productivity_report_summary_section_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DialogsProductivityReportSummarySection), 0, (GInstanceInitFunc) dialogs_productivity_report_summary_section_instance_init, NULL };
	GType dialogs_productivity_report_summary_section_type_id;
	dialogs_productivity_report_summary_section_type_id = g_type_register_static (adw_bin_get_type (), "DialogsProductivityReportSummarySection", &g_define_type_info, 0);
	DialogsProductivityReportSummarySection_private_offset = g_type_add_instance_private (dialogs_productivity_report_summary_section_type_id, sizeof (DialogsProductivityReportSummarySectionPrivate));
	return dialogs_productivity_report_summary_section_type_id;
}

GType
dialogs_productivity_report_summary_section_get_type (void)
{
	static volatile gsize dialogs_productivity_report_summary_section_type_id__once = 0;
	if (g_once_init_enter (&dialogs_productivity_report_summary_section_type_id__once)) {
		GType dialogs_productivity_report_summary_section_type_id;
		dialogs_productivity_report_summary_section_type_id = dialogs_productivity_report_summary_section_get_type_once ();
		g_once_init_leave (&dialogs_productivity_report_summary_section_type_id__once, dialogs_productivity_report_summary_section_type_id);
	}
	return dialogs_productivity_report_summary_section_type_id__once;
}

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);
}

