/* DynamicPreferencesGroup.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from DynamicPreferencesGroup.vala, do not modify */

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: Michael Terry
 */

#include <adwaita.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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 TYPE_DYNAMIC_PREFERENCES_GROUP (dynamic_preferences_group_get_type ())
#define DYNAMIC_PREFERENCES_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DYNAMIC_PREFERENCES_GROUP, DynamicPreferencesGroup))
#define DYNAMIC_PREFERENCES_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DYNAMIC_PREFERENCES_GROUP, DynamicPreferencesGroupClass))
#define IS_DYNAMIC_PREFERENCES_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DYNAMIC_PREFERENCES_GROUP))
#define IS_DYNAMIC_PREFERENCES_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DYNAMIC_PREFERENCES_GROUP))
#define DYNAMIC_PREFERENCES_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DYNAMIC_PREFERENCES_GROUP, DynamicPreferencesGroupClass))

typedef struct _DynamicPreferencesGroup DynamicPreferencesGroup;
typedef struct _DynamicPreferencesGroupClass DynamicPreferencesGroupClass;
typedef struct _DynamicPreferencesGroupPrivate DynamicPreferencesGroupPrivate;
enum  {
	DYNAMIC_PREFERENCES_GROUP_0_PROPERTY,
	DYNAMIC_PREFERENCES_GROUP_MODE_PROPERTY,
	DYNAMIC_PREFERENCES_GROUP_NUM_PROPERTIES
};
static GParamSpec* dynamic_preferences_group_properties[DYNAMIC_PREFERENCES_GROUP_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _DynamicPreferencesGroup {
	AdwPreferencesGroup parent_instance;
	DynamicPreferencesGroupPrivate * priv;
};

struct _DynamicPreferencesGroupClass {
	AdwPreferencesGroupClass parent_class;
};

struct _DynamicPreferencesGroupPrivate {
	gchar* _mode;
	GHashTable* children_types;
};

static gint DynamicPreferencesGroup_private_offset;
static gpointer dynamic_preferences_group_parent_class = NULL;
static GtkBuildableIface * dynamic_preferences_group_gtk_buildable_parent_iface = NULL;

VALA_EXTERN GType dynamic_preferences_group_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DynamicPreferencesGroup, g_object_unref)
static void _g_free0_ (gpointer var);
static void dynamic_preferences_group_real_add_child (GtkBuildable* base,
                                               GtkBuilder* builder,
                                               GObject* child,
                                               const gchar* type);
static void dynamic_preferences_group_reset_row_visibility (DynamicPreferencesGroup* self);
static void __lambda28_ (DynamicPreferencesGroup* self,
                  GtkWidget* child,
                  const gchar* type);
VALA_EXTERN const gchar* dynamic_preferences_group_get_mode (DynamicPreferencesGroup* self);
static void ___lambda28__gh_func (gconstpointer key,
                           gconstpointer value,
                           gpointer self);
VALA_EXTERN DynamicPreferencesGroup* dynamic_preferences_group_new (void);
VALA_EXTERN DynamicPreferencesGroup* dynamic_preferences_group_construct (GType object_type);
VALA_EXTERN void dynamic_preferences_group_set_mode (DynamicPreferencesGroup* self,
                                         const gchar* value);
static GObject * dynamic_preferences_group_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void _dynamic_preferences_group_reset_row_visibility_g_object_notify (GObject* _sender,
                                                                      GParamSpec* pspec,
                                                                      gpointer self);
static void dynamic_preferences_group_finalize (GObject * obj);
static GType dynamic_preferences_group_get_type_once (void);
static void _vala_dynamic_preferences_group_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_dynamic_preferences_group_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);

static inline gpointer
dynamic_preferences_group_get_instance_private (DynamicPreferencesGroup* self)
{
	return G_STRUCT_MEMBER_P (self, DynamicPreferencesGroup_private_offset);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

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

static void
dynamic_preferences_group_real_add_child (GtkBuildable* base,
                                          GtkBuilder* builder,
                                          GObject* child,
                                          const gchar* type)
{
	DynamicPreferencesGroup * self;
	GtkWidget* widget = NULL;
	GtkWidget* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GtkWidget* _tmp2_;
	self = (DynamicPreferencesGroup*) base;
	g_return_if_fail (builder != NULL);
	g_return_if_fail (child != NULL);
	dynamic_preferences_group_gtk_buildable_parent_iface->add_child ((GtkBuildable*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_preferences_group_get_type (), AdwPreferencesGroup), builder, child, NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (child, gtk_widget_get_type ()) ? ((GtkWidget*) child) : NULL);
	widget = _tmp0_;
	_tmp2_ = widget;
	if (_tmp2_ != NULL) {
		_tmp1_ = type != NULL;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GHashTable* _tmp3_;
		GtkWidget* _tmp4_;
		gchar* _tmp5_;
		GtkWidget* _tmp6_;
		_tmp3_ = self->priv->children_types;
		_tmp4_ = widget;
		_tmp5_ = g_strdup (type);
		g_hash_table_insert (_tmp3_, _tmp4_, _tmp5_);
		_tmp6_ = widget;
		gtk_widget_set_visible (_tmp6_, FALSE);
	}
	_g_object_unref0 (widget);
}

static void
__lambda28_ (DynamicPreferencesGroup* self,
             GtkWidget* child,
             const gchar* type)
{
	const gchar* _tmp0_;
	g_return_if_fail (child != NULL);
	g_return_if_fail (type != NULL);
	_tmp0_ = self->priv->_mode;
	gtk_widget_set_visible (child, g_strcmp0 (type, _tmp0_) == 0);
}

static void
___lambda28__gh_func (gconstpointer key,
                      gconstpointer value,
                      gpointer self)
{
	__lambda28_ ((DynamicPreferencesGroup*) self, (GtkWidget*) key, (const gchar*) value);
}

static void
dynamic_preferences_group_reset_row_visibility (DynamicPreferencesGroup* self)
{
	GHashTable* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->children_types;
	g_hash_table_foreach (_tmp0_, ___lambda28__gh_func, self);
}

DynamicPreferencesGroup*
dynamic_preferences_group_construct (GType object_type)
{
	DynamicPreferencesGroup * self = NULL;
	self = (DynamicPreferencesGroup*) g_object_new (object_type, NULL);
	return self;
}

DynamicPreferencesGroup*
dynamic_preferences_group_new (void)
{
	return dynamic_preferences_group_construct (TYPE_DYNAMIC_PREFERENCES_GROUP);
}

const gchar*
dynamic_preferences_group_get_mode (DynamicPreferencesGroup* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_mode;
	result = _tmp0_;
	return result;
}

void
dynamic_preferences_group_set_mode (DynamicPreferencesGroup* self,
                                    const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = dynamic_preferences_group_get_mode (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_mode);
		self->priv->_mode = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dynamic_preferences_group_properties[DYNAMIC_PREFERENCES_GROUP_MODE_PROPERTY]);
	}
}

static void
_dynamic_preferences_group_reset_row_visibility_g_object_notify (GObject* _sender,
                                                                 GParamSpec* pspec,
                                                                 gpointer self)
{
	dynamic_preferences_group_reset_row_visibility ((DynamicPreferencesGroup*) self);
}

static GObject *
dynamic_preferences_group_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DynamicPreferencesGroup * self;
	parent_class = G_OBJECT_CLASS (dynamic_preferences_group_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DYNAMIC_PREFERENCES_GROUP, DynamicPreferencesGroup);
	g_signal_connect_object ((GObject*) self, "notify::mode", (GCallback) _dynamic_preferences_group_reset_row_visibility_g_object_notify, self, 0);
	dynamic_preferences_group_reset_row_visibility (self);
	return obj;
}

static void
dynamic_preferences_group_class_init (DynamicPreferencesGroupClass * klass,
                                      gpointer klass_data)
{
	dynamic_preferences_group_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DynamicPreferencesGroup_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dynamic_preferences_group_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dynamic_preferences_group_set_property;
	G_OBJECT_CLASS (klass)->constructor = dynamic_preferences_group_constructor;
	G_OBJECT_CLASS (klass)->finalize = dynamic_preferences_group_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DYNAMIC_PREFERENCES_GROUP_MODE_PROPERTY, dynamic_preferences_group_properties[DYNAMIC_PREFERENCES_GROUP_MODE_PROPERTY] = g_param_spec_string ("mode", "mode", "mode", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
dynamic_preferences_group_gtk_buildable_interface_init (GtkBuildableIface * iface,
                                                        gpointer iface_data)
{
	dynamic_preferences_group_gtk_buildable_parent_iface = g_type_interface_peek_parent (iface);
	iface->add_child = (void (*) (GtkBuildable*, GtkBuilder*, GObject*, const gchar*)) dynamic_preferences_group_real_add_child;
}

static void
dynamic_preferences_group_instance_init (DynamicPreferencesGroup * self,
                                         gpointer klass)
{
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	self->priv = dynamic_preferences_group_get_instance_private (self);
	_tmp0_ = g_direct_hash;
	_tmp1_ = g_direct_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, NULL, _g_free0_);
	self->priv->children_types = _tmp2_;
}

static void
dynamic_preferences_group_finalize (GObject * obj)
{
	DynamicPreferencesGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DYNAMIC_PREFERENCES_GROUP, DynamicPreferencesGroup);
	_g_free0 (self->priv->_mode);
	_g_hash_table_unref0 (self->priv->children_types);
	G_OBJECT_CLASS (dynamic_preferences_group_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
dynamic_preferences_group_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DynamicPreferencesGroupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dynamic_preferences_group_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DynamicPreferencesGroup), 0, (GInstanceInitFunc) dynamic_preferences_group_instance_init, NULL };
	static const GInterfaceInfo gtk_buildable_info = { (GInterfaceInitFunc) dynamic_preferences_group_gtk_buildable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dynamic_preferences_group_type_id;
	dynamic_preferences_group_type_id = g_type_register_static (adw_preferences_group_get_type (), "DynamicPreferencesGroup", &g_define_type_info, 0);
	g_type_add_interface_static (dynamic_preferences_group_type_id, gtk_buildable_get_type (), &gtk_buildable_info);
	DynamicPreferencesGroup_private_offset = g_type_add_instance_private (dynamic_preferences_group_type_id, sizeof (DynamicPreferencesGroupPrivate));
	return dynamic_preferences_group_type_id;
}

GType
dynamic_preferences_group_get_type (void)
{
	static gsize dynamic_preferences_group_type_id__once = 0;
	if (g_once_init_enter (&dynamic_preferences_group_type_id__once)) {
		GType dynamic_preferences_group_type_id;
		dynamic_preferences_group_type_id = dynamic_preferences_group_get_type_once ();
		g_once_init_leave (&dynamic_preferences_group_type_id__once, dynamic_preferences_group_type_id);
	}
	return dynamic_preferences_group_type_id__once;
}

static void
_vala_dynamic_preferences_group_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	DynamicPreferencesGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_DYNAMIC_PREFERENCES_GROUP, DynamicPreferencesGroup);
	switch (property_id) {
		case DYNAMIC_PREFERENCES_GROUP_MODE_PROPERTY:
		g_value_set_string (value, dynamic_preferences_group_get_mode (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dynamic_preferences_group_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	DynamicPreferencesGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_DYNAMIC_PREFERENCES_GROUP, DynamicPreferencesGroup);
	switch (property_id) {
		case DYNAMIC_PREFERENCES_GROUP_MODE_PROPERTY:
		dynamic_preferences_group_set_mode (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

