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

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2017-2023 elementary, Inc. (https://elementary.io)
 *
 * Authored by: Leonhard Kargl <leo.kargl@proton.me>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <camel/camel.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 MAIL_TYPE_FOLDER_ROW (mail_folder_row_get_type ())
#define MAIL_FOLDER_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_FOLDER_ROW, MailFolderRow))
#define MAIL_FOLDER_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_TYPE_FOLDER_ROW, MailFolderRowClass))
#define MAIL_IS_FOLDER_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_TYPE_FOLDER_ROW))
#define MAIL_IS_FOLDER_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_TYPE_FOLDER_ROW))
#define MAIL_FOLDER_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_TYPE_FOLDER_ROW, MailFolderRowClass))

typedef struct _MailFolderRow MailFolderRow;
typedef struct _MailFolderRowClass MailFolderRowClass;
typedef struct _MailFolderRowPrivate MailFolderRowPrivate;
enum  {
	MAIL_FOLDER_ROW_0_PROPERTY,
	MAIL_FOLDER_ROW_DEPTH_PROPERTY,
	MAIL_FOLDER_ROW_FOLDER_INFO_PROPERTY,
	MAIL_FOLDER_ROW_STORE_PROPERTY,
	MAIL_FOLDER_ROW_POS_PROPERTY,
	MAIL_FOLDER_ROW_NUM_PROPERTIES
};
static GParamSpec* mail_folder_row_properties[MAIL_FOLDER_ROW_NUM_PROPERTIES];
#define __vala_CamelFolderInfo_free0(var) ((var == NULL) ? NULL : (var = (_vala_CamelFolderInfo_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _MailFolderRow {
	GtkListBoxRow parent_instance;
	MailFolderRowPrivate * priv;
};

struct _MailFolderRowClass {
	GtkListBoxRowClass parent_class;
};

struct _MailFolderRowPrivate {
	gint _depth;
	CamelFolderInfo* _folder_info;
	CamelStore* _store;
	gint _pos;
};

static gint MailFolderRow_private_offset;
static gpointer mail_folder_row_parent_class = NULL;

VALA_EXTERN GType mail_folder_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailFolderRow, g_object_unref)
static void _vala_CamelFolderInfo_free (CamelFolderInfo* self);
VALA_EXTERN MailFolderRow* mail_folder_row_new (gint depth,
                                    CamelFolderInfo* folder_info,
                                    CamelStore* store);
VALA_EXTERN MailFolderRow* mail_folder_row_construct (GType object_type,
                                          gint depth,
                                          CamelFolderInfo* folder_info,
                                          CamelStore* store);
VALA_EXTERN gint mail_folder_row_get_depth (MailFolderRow* self);
static void mail_folder_row_set_depth (MailFolderRow* self,
                                gint value);
VALA_EXTERN CamelFolderInfo* mail_folder_row_get_folder_info (MailFolderRow* self);
static void mail_folder_row_set_folder_info (MailFolderRow* self,
                                      CamelFolderInfo* value);
static CamelFolderInfo* _vala_CamelFolderInfo_copy (CamelFolderInfo* self);
VALA_EXTERN CamelStore* mail_folder_row_get_store (MailFolderRow* self);
static void mail_folder_row_set_store (MailFolderRow* self,
                                CamelStore* value);
VALA_EXTERN gint mail_folder_row_get_pos (MailFolderRow* self);
static void mail_folder_row_set_pos (MailFolderRow* self,
                              gint value);
static GObject * mail_folder_row_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties);
VALA_EXTERN CamelFolderInfoFlags mail_utils_get_full_folder_info_flags (CamelService* service,
                                                            CamelFolderInfo* folderinfo);
static void mail_folder_row_finalize (GObject * obj);
static GType mail_folder_row_get_type_once (void);
static void _vala_mail_folder_row_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_mail_folder_row_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);

static inline gpointer
mail_folder_row_get_instance_private (MailFolderRow* self)
{
	return G_STRUCT_MEMBER_P (self, MailFolderRow_private_offset);
}

static void
_vala_CamelFolderInfo_free (CamelFolderInfo* self)
{
	g_boxed_free (camel_folder_info_get_type (), self);
}

MailFolderRow*
mail_folder_row_construct (GType object_type,
                           gint depth,
                           CamelFolderInfo* folder_info,
                           CamelStore* store)
{
	MailFolderRow * self = NULL;
	g_return_val_if_fail (folder_info != NULL, NULL);
	g_return_val_if_fail (store != NULL, NULL);
	self = (MailFolderRow*) g_object_new (object_type, "depth", depth, "folder-info", folder_info, "store", store, NULL);
	return self;
}

MailFolderRow*
mail_folder_row_new (gint depth,
                     CamelFolderInfo* folder_info,
                     CamelStore* store)
{
	return mail_folder_row_construct (MAIL_TYPE_FOLDER_ROW, depth, folder_info, store);
}

gint
mail_folder_row_get_depth (MailFolderRow* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_depth;
	return result;
}

static void
mail_folder_row_set_depth (MailFolderRow* self,
                           gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = mail_folder_row_get_depth (self);
	if (old_value != value) {
		self->priv->_depth = value;
		g_object_notify_by_pspec ((GObject *) self, mail_folder_row_properties[MAIL_FOLDER_ROW_DEPTH_PROPERTY]);
	}
}

CamelFolderInfo*
mail_folder_row_get_folder_info (MailFolderRow* self)
{
	CamelFolderInfo* result;
	CamelFolderInfo* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_folder_info;
	result = _tmp0_;
	return result;
}

static CamelFolderInfo*
_vala_CamelFolderInfo_copy (CamelFolderInfo* self)
{
	return g_boxed_copy (camel_folder_info_get_type (), self);
}

static gpointer
__vala_CamelFolderInfo_copy0 (gpointer self)
{
	return self ? _vala_CamelFolderInfo_copy (self) : NULL;
}

static void
mail_folder_row_set_folder_info (MailFolderRow* self,
                                 CamelFolderInfo* value)
{
	CamelFolderInfo* old_value;
	g_return_if_fail (self != NULL);
	old_value = mail_folder_row_get_folder_info (self);
	if (old_value != value) {
		CamelFolderInfo* _tmp0_;
		_tmp0_ = __vala_CamelFolderInfo_copy0 (value);
		__vala_CamelFolderInfo_free0 (self->priv->_folder_info);
		self->priv->_folder_info = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, mail_folder_row_properties[MAIL_FOLDER_ROW_FOLDER_INFO_PROPERTY]);
	}
}

CamelStore*
mail_folder_row_get_store (MailFolderRow* self)
{
	CamelStore* result;
	CamelStore* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_store;
	result = _tmp0_;
	return result;
}

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

static void
mail_folder_row_set_store (MailFolderRow* self,
                           CamelStore* value)
{
	CamelStore* old_value;
	g_return_if_fail (self != NULL);
	old_value = mail_folder_row_get_store (self);
	if (old_value != value) {
		CamelStore* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_store);
		self->priv->_store = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, mail_folder_row_properties[MAIL_FOLDER_ROW_STORE_PROPERTY]);
	}
}

gint
mail_folder_row_get_pos (MailFolderRow* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_pos;
	return result;
}

static void
mail_folder_row_set_pos (MailFolderRow* self,
                         gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = mail_folder_row_get_pos (self);
	if (old_value != value) {
		self->priv->_pos = value;
		g_object_notify_by_pspec ((GObject *) self, mail_folder_row_properties[MAIL_FOLDER_ROW_POS_PROPERTY]);
	}
}

static GObject *
mail_folder_row_constructor (GType type,
                             guint n_construct_properties,
                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	MailFolderRow * self;
	GtkImage* icon = NULL;
	GtkImage* _tmp0_ = NULL;
	CamelFolderInfoFlags full_folder_info_flags = 0U;
	CamelStore* _tmp1_;
	CamelFolderInfo* _tmp2_;
	GtkBox* box = NULL;
	GtkBox* _tmp13_ = NULL;
	GtkBox* _tmp14_;
	GtkImage* _tmp15_;
	GtkBox* _tmp16_;
	CamelFolderInfo* _tmp17_;
	const gchar* _tmp18_;
	GtkLabel* _tmp19_;
	GtkLabel* _tmp20_;
	GtkBox* _tmp21_;
	parent_class = G_OBJECT_CLASS (mail_folder_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAIL_TYPE_FOLDER_ROW, MailFolderRow);
	_tmp0_ = (GtkImage*) gtk_image_new_from_icon_name ("folder", (GtkIconSize) GTK_ICON_SIZE_MENU);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp0_, 3);
	g_object_ref_sink (_tmp0_);
	icon = _tmp0_;
	_tmp1_ = self->priv->_store;
	_tmp2_ = self->priv->_folder_info;
	full_folder_info_flags = mail_utils_get_full_folder_info_flags ((CamelService*) _tmp1_, _tmp2_);
	switch (full_folder_info_flags & CAMEL_FOLDER_TYPE_MASK) {
		case CAMEL_FOLDER_TYPE_INBOX:
		{
			GtkImage* _tmp3_;
			_tmp3_ = icon;
			gtk_image_set_from_icon_name (_tmp3_, "mail-inbox", (GtkIconSize) GTK_ICON_SIZE_MENU);
			mail_folder_row_set_pos (self, 1);
			break;
		}
		case CAMEL_FOLDER_TYPE_DRAFTS:
		{
			GtkImage* _tmp4_;
			_tmp4_ = icon;
			gtk_image_set_from_icon_name (_tmp4_, "mail-drafts", (GtkIconSize) GTK_ICON_SIZE_MENU);
			mail_folder_row_set_pos (self, 2);
			break;
		}
		case CAMEL_FOLDER_TYPE_OUTBOX:
		{
			GtkImage* _tmp5_;
			_tmp5_ = icon;
			gtk_image_set_from_icon_name (_tmp5_, "mail-outbox", (GtkIconSize) GTK_ICON_SIZE_MENU);
			mail_folder_row_set_pos (self, 3);
			break;
		}
		case CAMEL_FOLDER_TYPE_SENT:
		{
			GtkImage* _tmp6_;
			_tmp6_ = icon;
			gtk_image_set_from_icon_name (_tmp6_, "mail-sent", (GtkIconSize) GTK_ICON_SIZE_MENU);
			mail_folder_row_set_pos (self, 4);
			break;
		}
		case CAMEL_FOLDER_TYPE_ARCHIVE:
		{
			GtkImage* _tmp7_;
			_tmp7_ = icon;
			gtk_image_set_from_icon_name (_tmp7_, "mail-archive", (GtkIconSize) GTK_ICON_SIZE_MENU);
			mail_folder_row_set_pos (self, 5);
			break;
		}
		case CAMEL_FOLDER_TYPE_TRASH:
		{
			const gchar* _tmp8_ = NULL;
			CamelFolderInfo* _tmp9_;
			GtkImage* _tmp10_;
			_tmp9_ = self->priv->_folder_info;
			if (_tmp9_->total == ((gint32) 0)) {
				_tmp8_ = "user-trash";
			} else {
				_tmp8_ = "user-trash-full";
			}
			_tmp10_ = icon;
			gtk_image_set_from_icon_name (_tmp10_, _tmp8_, (GtkIconSize) GTK_ICON_SIZE_MENU);
			mail_folder_row_set_pos (self, 6);
			break;
		}
		case CAMEL_FOLDER_TYPE_JUNK:
		{
			GtkImage* _tmp11_;
			_tmp11_ = icon;
			gtk_image_set_from_icon_name (_tmp11_, "edit-flag", (GtkIconSize) GTK_ICON_SIZE_MENU);
			mail_folder_row_set_pos (self, 7);
			break;
		}
		default:
		{
			GtkImage* _tmp12_;
			_tmp12_ = icon;
			gtk_image_set_from_icon_name (_tmp12_, "folder", (GtkIconSize) GTK_ICON_SIZE_MENU);
			mail_folder_row_set_pos (self, 8);
			break;
		}
	}
	_tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp13_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp13_, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp13_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp13_, 12);
	g_object_ref_sink (_tmp13_);
	box = _tmp13_;
	_tmp14_ = box;
	_tmp15_ = icon;
	gtk_container_add ((GtkContainer*) _tmp14_, (GtkWidget*) _tmp15_);
	_tmp16_ = box;
	_tmp17_ = self->priv->_folder_info;
	_tmp18_ = _tmp17_->display_name;
	_tmp19_ = (GtkLabel*) gtk_label_new (_tmp18_);
	g_object_ref_sink (_tmp19_);
	_tmp20_ = _tmp19_;
	gtk_container_add ((GtkContainer*) _tmp16_, (GtkWidget*) _tmp20_);
	_g_object_unref0 (_tmp20_);
	_tmp21_ = box;
	g_object_set ((GtkContainer*) self, "child", (GtkWidget*) _tmp21_, NULL);
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (box);
	_g_object_unref0 (icon);
	return obj;
}

static void
mail_folder_row_class_init (MailFolderRowClass * klass,
                            gpointer klass_data)
{
	mail_folder_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MailFolderRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_mail_folder_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_mail_folder_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = mail_folder_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = mail_folder_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAIL_FOLDER_ROW_DEPTH_PROPERTY, mail_folder_row_properties[MAIL_FOLDER_ROW_DEPTH_PROPERTY] = g_param_spec_int ("depth", "depth", "depth", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAIL_FOLDER_ROW_FOLDER_INFO_PROPERTY, mail_folder_row_properties[MAIL_FOLDER_ROW_FOLDER_INFO_PROPERTY] = g_param_spec_boxed ("folder-info", "folder-info", "folder-info", camel_folder_info_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAIL_FOLDER_ROW_STORE_PROPERTY, mail_folder_row_properties[MAIL_FOLDER_ROW_STORE_PROPERTY] = g_param_spec_object ("store", "store", "store", camel_store_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAIL_FOLDER_ROW_POS_PROPERTY, mail_folder_row_properties[MAIL_FOLDER_ROW_POS_PROPERTY] = g_param_spec_int ("pos", "pos", "pos", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
mail_folder_row_instance_init (MailFolderRow * self,
                               gpointer klass)
{
	self->priv = mail_folder_row_get_instance_private (self);
}

static void
mail_folder_row_finalize (GObject * obj)
{
	MailFolderRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAIL_TYPE_FOLDER_ROW, MailFolderRow);
	__vala_CamelFolderInfo_free0 (self->priv->_folder_info);
	_g_object_unref0 (self->priv->_store);
	G_OBJECT_CLASS (mail_folder_row_parent_class)->finalize (obj);
}

static GType
mail_folder_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MailFolderRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mail_folder_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MailFolderRow), 0, (GInstanceInitFunc) mail_folder_row_instance_init, NULL };
	GType mail_folder_row_type_id;
	mail_folder_row_type_id = g_type_register_static (gtk_list_box_row_get_type (), "MailFolderRow", &g_define_type_info, 0);
	MailFolderRow_private_offset = g_type_add_instance_private (mail_folder_row_type_id, sizeof (MailFolderRowPrivate));
	return mail_folder_row_type_id;
}

GType
mail_folder_row_get_type (void)
{
	static volatile gsize mail_folder_row_type_id__once = 0;
	if (g_once_init_enter (&mail_folder_row_type_id__once)) {
		GType mail_folder_row_type_id;
		mail_folder_row_type_id = mail_folder_row_get_type_once ();
		g_once_init_leave (&mail_folder_row_type_id__once, mail_folder_row_type_id);
	}
	return mail_folder_row_type_id__once;
}

static void
_vala_mail_folder_row_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	MailFolderRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, MAIL_TYPE_FOLDER_ROW, MailFolderRow);
	switch (property_id) {
		case MAIL_FOLDER_ROW_DEPTH_PROPERTY:
		g_value_set_int (value, mail_folder_row_get_depth (self));
		break;
		case MAIL_FOLDER_ROW_FOLDER_INFO_PROPERTY:
		g_value_set_boxed (value, mail_folder_row_get_folder_info (self));
		break;
		case MAIL_FOLDER_ROW_STORE_PROPERTY:
		g_value_set_object (value, mail_folder_row_get_store (self));
		break;
		case MAIL_FOLDER_ROW_POS_PROPERTY:
		g_value_set_int (value, mail_folder_row_get_pos (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_mail_folder_row_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	MailFolderRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, MAIL_TYPE_FOLDER_ROW, MailFolderRow);
	switch (property_id) {
		case MAIL_FOLDER_ROW_DEPTH_PROPERTY:
		mail_folder_row_set_depth (self, g_value_get_int (value));
		break;
		case MAIL_FOLDER_ROW_FOLDER_INFO_PROPERTY:
		mail_folder_row_set_folder_info (self, g_value_get_boxed (value));
		break;
		case MAIL_FOLDER_ROW_STORE_PROPERTY:
		mail_folder_row_set_store (self, g_value_get_object (value));
		break;
		case MAIL_FOLDER_ROW_POS_PROPERTY:
		mail_folder_row_set_pos (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

