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

/*
 * Copyright 2017-2022 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "granite-7.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <float.h>
#include <math.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  {
	GRANITE_SETTINGS_SIDEBAR_0_PROPERTY,
	GRANITE_SETTINGS_SIDEBAR_STACK_PROPERTY,
	GRANITE_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY,
	GRANITE_SETTINGS_SIDEBAR_NUM_PROPERTIES
};
static GParamSpec* granite_settings_sidebar_properties[GRANITE_SETTINGS_SIDEBAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GRANITE_TYPE_SETTINGS_SIDEBAR_ROW (granite_settings_sidebar_row_get_type ())
#define GRANITE_SETTINGS_SIDEBAR_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRANITE_TYPE_SETTINGS_SIDEBAR_ROW, GraniteSettingsSidebarRow))
#define GRANITE_SETTINGS_SIDEBAR_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRANITE_TYPE_SETTINGS_SIDEBAR_ROW, GraniteSettingsSidebarRowClass))
#define GRANITE_IS_SETTINGS_SIDEBAR_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRANITE_TYPE_SETTINGS_SIDEBAR_ROW))
#define GRANITE_IS_SETTINGS_SIDEBAR_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRANITE_TYPE_SETTINGS_SIDEBAR_ROW))
#define GRANITE_SETTINGS_SIDEBAR_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRANITE_TYPE_SETTINGS_SIDEBAR_ROW, GraniteSettingsSidebarRowClass))

typedef struct _GraniteSettingsSidebarRow GraniteSettingsSidebarRow;
typedef struct _GraniteSettingsSidebarRowClass GraniteSettingsSidebarRowClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GraniteSettingsSidebarPrivate {
	GtkListBox* listbox;
	GtkStack* _stack;
};

static gint GraniteSettingsSidebar_private_offset;
static gpointer granite_settings_sidebar_parent_class = NULL;

 G_GNUC_INTERNAL GType granite_settings_sidebar_row_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
 G_GNUC_INTERNAL GraniteSettingsPage* granite_settings_sidebar_row_get_page (GraniteSettingsSidebarRow* self);
static void granite_settings_sidebar_on_sidebar_changed (GraniteSettingsSidebar* self);
 G_GNUC_INTERNAL GraniteSettingsSidebarRow* granite_settings_sidebar_row_new (GraniteSettingsPage* page);
 G_GNUC_INTERNAL GraniteSettingsSidebarRow* granite_settings_sidebar_row_construct (GType object_type,
                                                                   GraniteSettingsPage* page);
static GObject * granite_settings_sidebar_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties);
static void _granite_settings_sidebar_on_sidebar_changed_g_list_model_items_changed (GListModel* _sender,
                                                                              guint position,
                                                                              guint removed,
                                                                              guint added,
                                                                              gpointer self);
static void _granite_settings_sidebar___lambda25_ (GraniteSettingsSidebar* self,
                                            GtkListBoxRow* row);
static void __granite_settings_sidebar___lambda25__gtk_list_box_row_selected (GtkListBox* _sender,
                                                                       GtkListBoxRow* row,
                                                                       gpointer self);
static void _granite_settings_sidebar___lambda26_ (GraniteSettingsSidebar* self,
                                            GtkListBoxRow* row,
                                            GtkListBoxRow* before);
 G_GNUC_INTERNAL const gchar* granite_settings_sidebar_row_get_header (GraniteSettingsSidebarRow* self);
static void __granite_settings_sidebar___lambda26__gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                             GtkListBoxRow* before,
                                                                             gpointer self);
static void _granite_settings_sidebar___lambda27_ (GraniteSettingsSidebar* self);
static void __granite_settings_sidebar___lambda27__g_object_notify (GObject* _sender,
                                                             GParamSpec* pspec,
                                                             gpointer self);
static void granite_settings_sidebar_finalize (GObject * obj);
static GType granite_settings_sidebar_get_type_once (void);
static void _vala_granite_settings_sidebar_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_granite_settings_sidebar_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);

static inline gpointer
granite_settings_sidebar_get_instance_private (GraniteSettingsSidebar* self)
{
	return G_STRUCT_MEMBER_P (self, GraniteSettingsSidebar_private_offset);
}

GtkStack*
granite_settings_sidebar_get_stack (GraniteSettingsSidebar* self)
{
	GtkStack* result;
	GtkStack* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_stack;
	result = _tmp0_;
	return result;
}

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

static void
granite_settings_sidebar_set_stack (GraniteSettingsSidebar* self,
                                    GtkStack* value)
{
	GtkStack* old_value;
	g_return_if_fail (self != NULL);
	old_value = granite_settings_sidebar_get_stack (self);
	if (old_value != value) {
		GtkStack* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_stack);
		self->priv->_stack = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, granite_settings_sidebar_properties[GRANITE_SETTINGS_SIDEBAR_STACK_PROPERTY]);
	}
}

const gchar*
granite_settings_sidebar_get_visible_child_name (GraniteSettingsSidebar* self)
{
	const gchar* result;
	GtkListBoxRow* selected_row = NULL;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->listbox;
	_tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	selected_row = _tmp2_;
	_tmp3_ = selected_row;
	if (_tmp3_ == NULL) {
		result = NULL;
		_g_object_unref0 (selected_row);
		return result;
	} else {
		GtkListBoxRow* _tmp4_;
		GraniteSettingsPage* _tmp5_;
		GraniteSettingsPage* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp4_ = selected_row;
		_tmp5_ = granite_settings_sidebar_row_get_page (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GRANITE_TYPE_SETTINGS_SIDEBAR_ROW, GraniteSettingsSidebarRow));
		_tmp6_ = _tmp5_;
		_tmp7_ = granite_settings_page_get_title (_tmp6_);
		_tmp8_ = _tmp7_;
		result = _tmp8_;
		_g_object_unref0 (selected_row);
		return result;
	}
}

void
granite_settings_sidebar_set_visible_child_name (GraniteSettingsSidebar* self,
                                                 const gchar* value)
{
	GtkWidget* listbox_child = NULL;
	GtkListBox* _tmp0_;
	GtkWidget* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->listbox;
	_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
	listbox_child = _tmp1_;
	while (TRUE) {
		GtkWidget* _tmp2_;
		GtkWidget* _tmp3_;
		GtkWidget* _tmp6_;
		GraniteSettingsPage* _tmp7_;
		GraniteSettingsPage* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		GtkWidget* _tmp13_;
		GtkWidget* _tmp14_;
		_tmp2_ = listbox_child;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = listbox_child;
		if (!GRANITE_IS_SETTINGS_SIDEBAR_ROW (_tmp3_)) {
			GtkWidget* _tmp4_;
			GtkWidget* _tmp5_;
			_tmp4_ = listbox_child;
			_tmp5_ = gtk_widget_get_next_sibling (_tmp4_);
			listbox_child = _tmp5_;
			continue;
		}
		_tmp6_ = listbox_child;
		_tmp7_ = granite_settings_sidebar_row_get_page (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GRANITE_TYPE_SETTINGS_SIDEBAR_ROW, GraniteSettingsSidebarRow));
		_tmp8_ = _tmp7_;
		_tmp9_ = granite_settings_page_get_title (_tmp8_);
		_tmp10_ = _tmp9_;
		if (g_strcmp0 (_tmp10_, value) == 0) {
			GtkListBox* _tmp11_;
			GtkWidget* _tmp12_;
			_tmp11_ = self->priv->listbox;
			_tmp12_ = listbox_child;
			gtk_list_box_select_row (_tmp11_, G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_list_box_row_get_type (), GtkListBoxRow));
			break;
		}
		_tmp13_ = listbox_child;
		_tmp14_ = gtk_widget_get_next_sibling (_tmp13_);
		listbox_child = _tmp14_;
	}
	g_object_notify_by_pspec ((GObject *) self, granite_settings_sidebar_properties[GRANITE_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY]);
}

/**
     * Create a new SettingsSidebar
     */
GraniteSettingsSidebar*
granite_settings_sidebar_construct (GType object_type,
                                    GtkStack* stack)
{
	GraniteSettingsSidebar * self = NULL;
	g_return_val_if_fail (stack != NULL, NULL);
	self = (GraniteSettingsSidebar*) g_object_new (object_type, "stack", stack, NULL);
	return self;
}

GraniteSettingsSidebar*
granite_settings_sidebar_new (GtkStack* stack)
{
	return granite_settings_sidebar_construct (GRANITE_TYPE_SETTINGS_SIDEBAR, stack);
}

static void
granite_settings_sidebar_on_sidebar_changed (GraniteSettingsSidebar* self)
{
	GtkWidget* listbox_child = NULL;
	GtkListBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* child = NULL;
	GtkStack* _tmp8_;
	GtkWidget* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->listbox;
	_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
	listbox_child = _tmp1_;
	while (TRUE) {
		GtkWidget* _tmp2_;
		GtkWidget* next_child = NULL;
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		GtkListBox* _tmp5_;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		_tmp2_ = listbox_child;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = listbox_child;
		_tmp4_ = gtk_widget_get_next_sibling (_tmp3_);
		next_child = _tmp4_;
		_tmp5_ = self->priv->listbox;
		_tmp6_ = listbox_child;
		gtk_list_box_remove (_tmp5_, _tmp6_);
		_tmp7_ = next_child;
		listbox_child = _tmp7_;
	}
	_tmp8_ = self->priv->_stack;
	_tmp9_ = gtk_widget_get_first_child ((GtkWidget*) _tmp8_);
	child = _tmp9_;
	while (TRUE) {
		GtkWidget* _tmp10_;
		GtkWidget* _tmp11_;
		GtkWidget* _tmp16_;
		GtkWidget* _tmp17_;
		_tmp10_ = child;
		if (!(_tmp10_ != NULL)) {
			break;
		}
		_tmp11_ = child;
		if (GRANITE_IS_SETTINGS_PAGE (_tmp11_)) {
			GraniteSettingsSidebarRow* row = NULL;
			GtkWidget* _tmp12_;
			GraniteSettingsSidebarRow* _tmp13_;
			GtkListBox* _tmp14_;
			GraniteSettingsSidebarRow* _tmp15_;
			_tmp12_ = child;
			_tmp13_ = granite_settings_sidebar_row_new (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GRANITE_TYPE_SETTINGS_PAGE, GraniteSettingsPage));
			g_object_ref_sink (_tmp13_);
			row = _tmp13_;
			_tmp14_ = self->priv->listbox;
			_tmp15_ = row;
			gtk_list_box_append (_tmp14_, (GtkWidget*) _tmp15_);
			_g_object_unref0 (row);
		}
		_tmp16_ = child;
		_tmp17_ = gtk_widget_get_next_sibling (_tmp16_);
		child = _tmp17_;
	}
}

static void
_granite_settings_sidebar_on_sidebar_changed_g_list_model_items_changed (GListModel* _sender,
                                                                         guint position,
                                                                         guint removed,
                                                                         guint added,
                                                                         gpointer self)
{
	granite_settings_sidebar_on_sidebar_changed ((GraniteSettingsSidebar*) self);
}

static void
_granite_settings_sidebar___lambda25_ (GraniteSettingsSidebar* self,
                                       GtkListBoxRow* row)
{
	GtkStack* _tmp0_;
	GraniteSettingsPage* _tmp1_;
	GraniteSettingsPage* _tmp2_;
	_tmp0_ = self->priv->_stack;
	_tmp1_ = granite_settings_sidebar_row_get_page (G_TYPE_CHECK_INSTANCE_CAST (row, GRANITE_TYPE_SETTINGS_SIDEBAR_ROW, GraniteSettingsSidebarRow));
	_tmp2_ = _tmp1_;
	gtk_stack_set_visible_child (_tmp0_, (GtkWidget*) _tmp2_);
}

static void
__granite_settings_sidebar___lambda25__gtk_list_box_row_selected (GtkListBox* _sender,
                                                                  GtkListBoxRow* row,
                                                                  gpointer self)
{
	_granite_settings_sidebar___lambda25_ ((GraniteSettingsSidebar*) self, row);
}

static void
_granite_settings_sidebar___lambda26_ (GraniteSettingsSidebar* self,
                                       GtkListBoxRow* row,
                                       GtkListBoxRow* before)
{
	gchar* header = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (row != NULL);
	_tmp0_ = granite_settings_sidebar_row_get_header (G_TYPE_CHECK_INSTANCE_CAST (row, GRANITE_TYPE_SETTINGS_SIDEBAR_ROW, GraniteSettingsSidebarRow));
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	header = _tmp2_;
	_tmp3_ = header;
	if (_tmp3_ != NULL) {
		GtkLabel* label = NULL;
		const gchar* _tmp4_;
		GtkLabel* _tmp5_ = NULL;
		GtkLabel* _tmp6_;
		GtkLabel* _tmp7_;
		_tmp4_ = header;
		_tmp5_ = (GtkLabel*) gtk_label_new (_tmp4_);
		gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_START);
		gtk_label_set_xalign (_tmp5_, (gfloat) 0);
		g_object_ref_sink (_tmp5_);
		label = _tmp5_;
		_tmp6_ = label;
		gtk_widget_add_css_class ((GtkWidget*) _tmp6_, GRANITE_STYLE_CLASS_H4_LABEL);
		_tmp7_ = label;
		gtk_list_box_row_set_header (row, (GtkWidget*) _tmp7_);
		_g_object_unref0 (label);
	}
	_g_free0 (header);
}

static void
__granite_settings_sidebar___lambda26__gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                        GtkListBoxRow* before,
                                                                        gpointer self)
{
	_granite_settings_sidebar___lambda26_ ((GraniteSettingsSidebar*) self, row, before);
}

static void
_granite_settings_sidebar___lambda27_ (GraniteSettingsSidebar* self)
{
	GtkStack* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	_tmp0_ = self->priv->_stack;
	_tmp1_ = gtk_stack_get_visible_child_name (_tmp0_);
	_tmp2_ = _tmp1_;
	granite_settings_sidebar_set_visible_child_name (self, _tmp2_);
}

static void
__granite_settings_sidebar___lambda27__g_object_notify (GObject* _sender,
                                                        GParamSpec* pspec,
                                                        gpointer self)
{
	_granite_settings_sidebar___lambda27_ ((GraniteSettingsSidebar*) self);
}

static GObject *
granite_settings_sidebar_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GraniteSettingsSidebar * self;
	GtkListBox* _tmp0_ = NULL;
	GtkScrolledWindow* scrolled = NULL;
	GtkListBox* _tmp1_;
	GtkWidget* _tmp2_;
	GtkScrolledWindow* _tmp3_ = NULL;
	GtkScrolledWindow* _tmp4_;
	GtkStack* _tmp5_;
	GtkSelectionModel* _tmp6_;
	GtkSelectionModel* _tmp7_;
	GtkSelectionModel* _tmp8_;
	GtkListBox* _tmp9_;
	GtkListBox* _tmp10_;
	GtkStack* _tmp11_;
	parent_class = G_OBJECT_CLASS (granite_settings_sidebar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_TYPE_SETTINGS_SIDEBAR, GraniteSettingsSidebar);
	_tmp0_ = (GtkListBox*) gtk_list_box_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp0_, TRUE);
	gtk_list_box_set_activate_on_single_click (_tmp0_, TRUE);
	gtk_list_box_set_selection_mode (_tmp0_, GTK_SELECTION_SINGLE);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->listbox);
	self->priv->listbox = _tmp0_;
	_tmp1_ = self->priv->listbox;
	_tmp2_ = _g_object_ref0 ((GtkWidget*) _tmp1_);
	_tmp3_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_set (_tmp3_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_scrolled_window_set_child (_tmp3_, _tmp2_);
	_g_object_unref0 (_tmp2_);
	g_object_ref_sink (_tmp3_);
	scrolled = _tmp3_;
	_tmp4_ = scrolled;
	gtk_widget_set_parent ((GtkWidget*) _tmp4_, (GtkWidget*) self);
	granite_settings_sidebar_on_sidebar_changed (self);
	_tmp5_ = self->priv->_stack;
	_tmp6_ = gtk_stack_get_pages (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	g_signal_connect_object ((GListModel*) _tmp8_, "items-changed", (GCallback) _granite_settings_sidebar_on_sidebar_changed_g_list_model_items_changed, self, 0);
	_g_object_unref0 (_tmp8_);
	_tmp9_ = self->priv->listbox;
	g_signal_connect_object (_tmp9_, "row-selected", (GCallback) __granite_settings_sidebar___lambda25__gtk_list_box_row_selected, self, 0);
	_tmp10_ = self->priv->listbox;
	gtk_list_box_set_header_func (_tmp10_, __granite_settings_sidebar___lambda26__gtk_list_box_update_header_func, g_object_ref (self), g_object_unref);
	_tmp11_ = self->priv->_stack;
	g_signal_connect_object ((GObject*) _tmp11_, "notify::visible-child-name", (GCallback) __granite_settings_sidebar___lambda27__g_object_notify, self, 0);
	_g_object_unref0 (scrolled);
	return obj;
}

static void
granite_settings_sidebar_base_init (GraniteSettingsSidebarClass * klass)
{
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "settingssidebar");
}

static void
granite_settings_sidebar_class_init (GraniteSettingsSidebarClass * klass,
                                     gpointer klass_data)
{
	granite_settings_sidebar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraniteSettingsSidebar_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_granite_settings_sidebar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_granite_settings_sidebar_set_property;
	G_OBJECT_CLASS (klass)->constructor = granite_settings_sidebar_constructor;
	G_OBJECT_CLASS (klass)->finalize = granite_settings_sidebar_finalize;
	/**
	     * The Gtk.Stack to control
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_SETTINGS_SIDEBAR_STACK_PROPERTY, granite_settings_sidebar_properties[GRANITE_SETTINGS_SIDEBAR_STACK_PROPERTY] = g_param_spec_object ("stack", "stack", "stack", gtk_stack_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	/**
	     * The name of the currently visible Granite.SettingsPage
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRANITE_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY, granite_settings_sidebar_properties[GRANITE_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY] = g_param_spec_string ("visible-child-name", "visible-child-name", "visible-child-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_layout_manager_type (GTK_WIDGET_CLASS (klass), gtk_bin_layout_get_type ());
}

static void
granite_settings_sidebar_instance_init (GraniteSettingsSidebar * self,
                                        gpointer klass)
{
	self->priv = granite_settings_sidebar_get_instance_private (self);
}

static void
granite_settings_sidebar_finalize (GObject * obj)
{
	GraniteSettingsSidebar * self;
	GtkWidget* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRANITE_TYPE_SETTINGS_SIDEBAR, GraniteSettingsSidebar);
	_tmp0_ = gtk_widget_get_first_child ((GtkWidget*) self);
	gtk_widget_unparent (_tmp0_);
	_g_object_unref0 (self->priv->listbox);
	_g_object_unref0 (self->priv->_stack);
	G_OBJECT_CLASS (granite_settings_sidebar_parent_class)->finalize (obj);
}

/**
 * SettingsSidebar acts as a controller for a Gtk.Stack; it shows a row of buttons
 * to switch between the various pages of the associated stack widget.
 *
 * All the content for the rows comes from the child properties of a Granite.SettingsPage
 * inside of the Gtk.Stack
 */
static GType
granite_settings_sidebar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraniteSettingsSidebarClass), (GBaseInitFunc) granite_settings_sidebar_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) granite_settings_sidebar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraniteSettingsSidebar), 0, (GInstanceInitFunc) granite_settings_sidebar_instance_init, NULL };
	GType granite_settings_sidebar_type_id;
	granite_settings_sidebar_type_id = g_type_register_static (gtk_widget_get_type (), "GraniteSettingsSidebar", &g_define_type_info, 0);
	GraniteSettingsSidebar_private_offset = g_type_add_instance_private (granite_settings_sidebar_type_id, sizeof (GraniteSettingsSidebarPrivate));
	return granite_settings_sidebar_type_id;
}

GType
granite_settings_sidebar_get_type (void)
{
	static volatile gsize granite_settings_sidebar_type_id__once = 0;
	if (g_once_init_enter (&granite_settings_sidebar_type_id__once)) {
		GType granite_settings_sidebar_type_id;
		granite_settings_sidebar_type_id = granite_settings_sidebar_get_type_once ();
		g_once_init_leave (&granite_settings_sidebar_type_id__once, granite_settings_sidebar_type_id);
	}
	return granite_settings_sidebar_type_id__once;
}

static void
_vala_granite_settings_sidebar_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GraniteSettingsSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_TYPE_SETTINGS_SIDEBAR, GraniteSettingsSidebar);
	switch (property_id) {
		case GRANITE_SETTINGS_SIDEBAR_STACK_PROPERTY:
		g_value_set_object (value, granite_settings_sidebar_get_stack (self));
		break;
		case GRANITE_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY:
		g_value_set_string (value, granite_settings_sidebar_get_visible_child_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_granite_settings_sidebar_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	GraniteSettingsSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRANITE_TYPE_SETTINGS_SIDEBAR, GraniteSettingsSidebar);
	switch (property_id) {
		case GRANITE_SETTINGS_SIDEBAR_STACK_PROPERTY:
		granite_settings_sidebar_set_stack (self, g_value_get_object (value));
		break;
		case GRANITE_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY:
		granite_settings_sidebar_set_visible_child_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

