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

/*
 * Copyright (c) 2024-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_ui.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib-object.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

enum  {
	FT_SIDEBAR_ROW_0_PROPERTY,
	FT_SIDEBAR_ROW_ICON_NAME_PROPERTY,
	FT_SIDEBAR_ROW_TITLE_PROPERTY,
	FT_SIDEBAR_ROW_SUFFIX_PROPERTY,
	FT_SIDEBAR_ROW_NUM_PROPERTIES
};
static GParamSpec* ft_sidebar_row_properties[FT_SIDEBAR_ROW_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 _FtSidebarRowPrivate {
	gchar* _title;
	GtkImage* icon;
	gchar* _icon_name;
	GtkWidget* _suffix;
};

static gint FtSidebarRow_private_offset;
static gpointer ft_sidebar_row_parent_class = NULL;

static void ft_sidebar_row_real_dispose (GObject* base);
static void ft_sidebar_row_finalize (GObject * obj);
static GType ft_sidebar_row_get_type_once (void);
static void _vala_ft_sidebar_row_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
static void _vala_ft_sidebar_row_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
ft_sidebar_row_get_instance_private (FtSidebarRow* self)
{
	return G_STRUCT_MEMBER_P (self, FtSidebarRow_private_offset);
}

static void
ft_sidebar_row_real_dispose (GObject* base)
{
	FtSidebarRow * self;
	self = (FtSidebarRow*) base;
	_g_object_unref0 (self->priv->_suffix);
	self->priv->_suffix = NULL;
	G_OBJECT_CLASS (ft_sidebar_row_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox));
}

FtSidebarRow*
ft_sidebar_row_construct (GType object_type)
{
	FtSidebarRow * self = NULL;
	self = (FtSidebarRow*) g_object_new (object_type, NULL);
	return self;
}

FtSidebarRow*
ft_sidebar_row_new (void)
{
	return ft_sidebar_row_construct (FT_TYPE_SIDEBAR_ROW);
}

const gchar*
ft_sidebar_row_get_icon_name (FtSidebarRow* 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
ft_sidebar_row_set_icon_name (FtSidebarRow* self,
                              const gchar* value)
{
	gchar* _tmp0_;
	GtkImage* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_icon_name);
	self->priv->_icon_name = _tmp0_;
	_tmp1_ = self->priv->icon;
	gtk_widget_set_visible ((GtkWidget*) _tmp1_, g_strcmp0 (value, "") != 0);
	g_object_notify_by_pspec ((GObject *) self, ft_sidebar_row_properties[FT_SIDEBAR_ROW_ICON_NAME_PROPERTY]);
}

const gchar*
ft_sidebar_row_get_title (FtSidebarRow* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_title;
	result = _tmp0_;
	return result;
}

void
ft_sidebar_row_set_title (FtSidebarRow* self,
                          const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_sidebar_row_get_title (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_title);
		self->priv->_title = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, ft_sidebar_row_properties[FT_SIDEBAR_ROW_TITLE_PROPERTY]);
	}
}

GtkWidget*
ft_sidebar_row_get_suffix (FtSidebarRow* self)
{
	GtkWidget* result;
	GtkWidget* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_suffix;
	result = _tmp0_;
	return result;
}

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

void
ft_sidebar_row_set_suffix (FtSidebarRow* self,
                           GtkWidget* value)
{
	GtkWidget* _tmp0_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_suffix;
	if (_tmp0_ != NULL) {
		GtkWidget* _tmp1_;
		_tmp1_ = self->priv->_suffix;
		gtk_box_remove (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), _tmp1_);
	}
	_tmp2_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_suffix);
	self->priv->_suffix = _tmp2_;
	_tmp3_ = self->priv->_suffix;
	if (_tmp3_ != NULL) {
		GtkWidget* _tmp4_;
		_tmp4_ = self->priv->_suffix;
		gtk_box_append (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox), _tmp4_);
	}
	g_object_notify_by_pspec ((GObject *) self, ft_sidebar_row_properties[FT_SIDEBAR_ROW_SUFFIX_PROPERTY]);
}

static void
ft_sidebar_row_class_init (FtSidebarRowClass * klass,
                           gpointer klass_data)
{
	ft_sidebar_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtSidebarRow_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_sidebar_row_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_sidebar_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_sidebar_row_set_property;
	G_OBJECT_CLASS (klass)->finalize = ft_sidebar_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SIDEBAR_ROW_ICON_NAME_PROPERTY, ft_sidebar_row_properties[FT_SIDEBAR_ROW_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_object_class_install_property (G_OBJECT_CLASS (klass), FT_SIDEBAR_ROW_TITLE_PROPERTY, ft_sidebar_row_properties[FT_SIDEBAR_ROW_TITLE_PROPERTY] = g_param_spec_string ("title", "title", "title", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SIDEBAR_ROW_SUFFIX_PROPERTY, ft_sidebar_row_properties[FT_SIDEBAR_ROW_SUFFIX_PROPERTY] = g_param_spec_object ("suffix", "suffix", "suffix", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/widgets/sidebar-row.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "icon", FALSE, FtSidebarRow_private_offset + G_STRUCT_OFFSET (FtSidebarRowPrivate, icon));
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "row");
}

static void
ft_sidebar_row_instance_init (FtSidebarRow * self,
                              gpointer klass)
{
	self->priv = ft_sidebar_row_get_instance_private (self);
	self->priv->_suffix = NULL;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_sidebar_row_finalize (GObject * obj)
{
	FtSidebarRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_SIDEBAR_ROW, FtSidebarRow);
	_g_free0 (self->priv->_title);
	_g_free0 (self->priv->_icon_name);
	_g_object_unref0 (self->priv->_suffix);
	G_OBJECT_CLASS (ft_sidebar_row_parent_class)->finalize (obj);
}

static GType
ft_sidebar_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtSidebarRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_sidebar_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtSidebarRow), 0, (GInstanceInitFunc) ft_sidebar_row_instance_init, NULL };
	GType ft_sidebar_row_type_id;
	ft_sidebar_row_type_id = g_type_register_static (gtk_box_get_type (), "FtSidebarRow", &g_define_type_info, 0);
	FtSidebarRow_private_offset = g_type_add_instance_private (ft_sidebar_row_type_id, sizeof (FtSidebarRowPrivate));
	return ft_sidebar_row_type_id;
}

GType
ft_sidebar_row_get_type (void)
{
	static volatile gsize ft_sidebar_row_type_id__once = 0;
	if (g_once_init_enter (&ft_sidebar_row_type_id__once)) {
		GType ft_sidebar_row_type_id;
		ft_sidebar_row_type_id = ft_sidebar_row_get_type_once ();
		g_once_init_leave (&ft_sidebar_row_type_id__once, ft_sidebar_row_type_id);
	}
	return ft_sidebar_row_type_id__once;
}

static void
_vala_ft_sidebar_row_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec)
{
	FtSidebarRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SIDEBAR_ROW, FtSidebarRow);
	switch (property_id) {
		case FT_SIDEBAR_ROW_ICON_NAME_PROPERTY:
		g_value_set_string (value, ft_sidebar_row_get_icon_name (self));
		break;
		case FT_SIDEBAR_ROW_TITLE_PROPERTY:
		g_value_set_string (value, ft_sidebar_row_get_title (self));
		break;
		case FT_SIDEBAR_ROW_SUFFIX_PROPERTY:
		g_value_set_object (value, ft_sidebar_row_get_suffix (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_sidebar_row_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec)
{
	FtSidebarRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SIDEBAR_ROW, FtSidebarRow);
	switch (property_id) {
		case FT_SIDEBAR_ROW_ICON_NAME_PROPERTY:
		ft_sidebar_row_set_icon_name (self, g_value_get_string (value));
		break;
		case FT_SIDEBAR_ROW_TITLE_PROPERTY:
		ft_sidebar_row_set_title (self, g_value_get_string (value));
		break;
		case FT_SIDEBAR_ROW_SUFFIX_PROPERTY:
		ft_sidebar_row_set_suffix (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

