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

/*
 * Copyright 2025 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include "granite-7.h"
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.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_DEMO_PAGE (demo_page_get_type ())
#define DEMO_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DEMO_PAGE, DemoPage))
#define DEMO_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DEMO_PAGE, DemoPageClass))
#define IS_DEMO_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DEMO_PAGE))
#define IS_DEMO_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DEMO_PAGE))
#define DEMO_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DEMO_PAGE, DemoPageClass))

typedef struct _DemoPage DemoPage;
typedef struct _DemoPageClass DemoPageClass;
typedef struct _DemoPagePrivate DemoPagePrivate;
enum  {
	DEMO_PAGE_0_PROPERTY,
	DEMO_PAGE_TITLE_PROPERTY,
	DEMO_PAGE_CHILD_PROPERTY,
	DEMO_PAGE_NUM_PROPERTIES
};
static GParamSpec* demo_page_properties[DEMO_PAGE_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 _DemoPage {
	GraniteToolBox parent_instance;
	DemoPagePrivate * priv;
};

struct _DemoPageClass {
	GraniteToolBoxClass parent_class;
};

struct _DemoPagePrivate {
	gchar* _title;
	GtkScrolledWindow* scrolled_window;
};

static gint DemoPage_private_offset;
static gpointer demo_page_parent_class = NULL;

VALA_EXTERN GType demo_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DemoPage, g_object_unref)
VALA_EXTERN const gchar* demo_page_get_title (DemoPage* self);
VALA_EXTERN void demo_page_set_title (DemoPage* self,
                          const gchar* value);
VALA_EXTERN void demo_page_set_child (DemoPage* self,
                          GtkWidget* value);
VALA_EXTERN DemoPage* demo_page_new (void);
VALA_EXTERN DemoPage* demo_page_construct (GType object_type);
static GObject * demo_page_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties);
static void demo_page_finalize (GObject * obj);
static GType demo_page_get_type_once (void);
static void _vala_demo_page_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec);
static void _vala_demo_page_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec);

static inline gpointer
demo_page_get_instance_private (DemoPage* self)
{
	return G_STRUCT_MEMBER_P (self, DemoPage_private_offset);
}

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

void
demo_page_set_title (DemoPage* self,
                     const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = demo_page_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, demo_page_properties[DEMO_PAGE_TITLE_PROPERTY]);
	}
}

void
demo_page_set_child (DemoPage* self,
                     GtkWidget* value)
{
	GtkScrolledWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->scrolled_window;
	gtk_scrolled_window_set_child (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, demo_page_properties[DEMO_PAGE_CHILD_PROPERTY]);
}

DemoPage*
demo_page_construct (GType object_type)
{
	DemoPage * self = NULL;
	self = (DemoPage*) granite_tool_box_construct (object_type);
	return self;
}

DemoPage*
demo_page_new (void)
{
	return demo_page_construct (TYPE_DEMO_PAGE);
}

static GObject *
demo_page_constructor (GType type,
                       guint n_construct_properties,
                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DemoPage * self;
	GraniteHeaderLabel* header_label = NULL;
	GraniteHeaderLabel* _tmp0_ = NULL;
	GraniteBox* header_box = NULL;
	GraniteBox* _tmp1_ = NULL;
	GraniteBox* _tmp2_;
	GraniteHeaderLabel* _tmp3_;
	GraniteBox* _tmp4_;
	GtkWindowControls* _tmp5_ = NULL;
	GtkWindowControls* _tmp6_;
	GraniteBox* _tmp7_;
	GtkScrolledWindow* _tmp8_ = NULL;
	GtkScrolledWindow* _tmp9_;
	GraniteHeaderLabel* _tmp10_;
	parent_class = G_OBJECT_CLASS (demo_page_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DEMO_PAGE, DemoPage);
	_tmp0_ = granite_header_label_new ("");
	gtk_widget_set_hexpand ((GtkWidget*) _tmp0_, TRUE);
	granite_header_label_set_size (_tmp0_, GRANITE_HEADER_LABEL_SIZE_H2);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp0_, 3);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp0_, 3);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp0_, 3);
	g_object_ref_sink (_tmp0_);
	header_label = _tmp0_;
	_tmp1_ = granite_box_new (GTK_ORIENTATION_HORIZONTAL, GRANITE_BOX_SPACING_SINGLE);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp1_, 6);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp1_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp1_, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp1_, 6);
	g_object_ref_sink (_tmp1_);
	header_box = _tmp1_;
	_tmp2_ = header_box;
	_tmp3_ = header_label;
	gtk_box_append ((GtkBox*) _tmp2_, (GtkWidget*) _tmp3_);
	_tmp4_ = header_box;
	_tmp5_ = (GtkWindowControls*) gtk_window_controls_new (GTK_PACK_END);
	gtk_widget_set_valign ((GtkWidget*) _tmp5_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp5_);
	_tmp6_ = _tmp5_;
	gtk_box_append ((GtkBox*) _tmp4_, (GtkWidget*) _tmp6_);
	_g_object_unref0 (_tmp6_);
	_tmp7_ = header_box;
	granite_tool_box_add_top_bar ((GraniteToolBox*) self, (GtkWidget*) _tmp7_);
	_tmp8_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_set (_tmp8_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp8_, TRUE);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->scrolled_window);
	self->priv->scrolled_window = _tmp8_;
	_tmp9_ = self->priv->scrolled_window;
	granite_tool_box_set_content ((GraniteToolBox*) self, (GtkWidget*) _tmp9_);
	_tmp10_ = header_label;
	g_object_bind_property_with_closures ((GObject*) self, "title", (GObject*) _tmp10_, "label", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_g_object_unref0 (header_box);
	_g_object_unref0 (header_label);
	return obj;
}

static void
demo_page_class_init (DemoPageClass * klass,
                      gpointer klass_data)
{
	demo_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DemoPage_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_demo_page_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_demo_page_set_property;
	G_OBJECT_CLASS (klass)->constructor = demo_page_constructor;
	G_OBJECT_CLASS (klass)->finalize = demo_page_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEMO_PAGE_TITLE_PROPERTY, demo_page_properties[DEMO_PAGE_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), DEMO_PAGE_CHILD_PROPERTY, demo_page_properties[DEMO_PAGE_CHILD_PROPERTY] = g_param_spec_object ("child", "child", "child", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
}

static void
demo_page_instance_init (DemoPage * self,
                         gpointer klass)
{
	self->priv = demo_page_get_instance_private (self);
}

static void
demo_page_finalize (GObject * obj)
{
	DemoPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DEMO_PAGE, DemoPage);
	_g_free0 (self->priv->_title);
	_g_object_unref0 (self->priv->scrolled_window);
	G_OBJECT_CLASS (demo_page_parent_class)->finalize (obj);
}

static GType
demo_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DemoPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) demo_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DemoPage), 0, (GInstanceInitFunc) demo_page_instance_init, NULL };
	GType demo_page_type_id;
	demo_page_type_id = g_type_register_static (GRANITE_TYPE_TOOL_BOX, "DemoPage", &g_define_type_info, 0);
	DemoPage_private_offset = g_type_add_instance_private (demo_page_type_id, sizeof (DemoPagePrivate));
	return demo_page_type_id;
}

GType
demo_page_get_type (void)
{
	static volatile gsize demo_page_type_id__once = 0;
	if (g_once_init_enter (&demo_page_type_id__once)) {
		GType demo_page_type_id;
		demo_page_type_id = demo_page_get_type_once ();
		g_once_init_leave (&demo_page_type_id__once, demo_page_type_id);
	}
	return demo_page_type_id__once;
}

static void
_vala_demo_page_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec)
{
	DemoPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_DEMO_PAGE, DemoPage);
	switch (property_id) {
		case DEMO_PAGE_TITLE_PROPERTY:
		g_value_set_string (value, demo_page_get_title (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_demo_page_set_property (GObject * object,
                              guint property_id,
                              const GValue * value,
                              GParamSpec * pspec)
{
	DemoPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_DEMO_PAGE, DemoPage);
	switch (property_id) {
		case DEMO_PAGE_TITLE_PROPERTY:
		demo_page_set_title (self, g_value_get_string (value));
		break;
		case DEMO_PAGE_CHILD_PROPERTY:
		demo_page_set_child (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

