/* 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 "switchboard.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <adwaita.h>
#include <granite-7.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  {
	SWITCHBOARD_SETTINGS_SIDEBAR_0_PROPERTY,
	SWITCHBOARD_SETTINGS_SIDEBAR_STACK_PROPERTY,
	SWITCHBOARD_SETTINGS_SIDEBAR_SHOW_TITLE_BUTTONS_PROPERTY,
	SWITCHBOARD_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY,
	SWITCHBOARD_SETTINGS_SIDEBAR_NUM_PROPERTIES
};
static GParamSpec* switchboard_settings_sidebar_properties[SWITCHBOARD_SETTINGS_SIDEBAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW (switchboard_settings_sidebar_row_get_type ())
#define SWITCHBOARD_SETTINGS_SIDEBAR_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW, SwitchboardSettingsSidebarRow))
#define SWITCHBOARD_SETTINGS_SIDEBAR_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW, SwitchboardSettingsSidebarRowClass))
#define SWITCHBOARD_IS_SETTINGS_SIDEBAR_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW))
#define SWITCHBOARD_IS_SETTINGS_SIDEBAR_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW))
#define SWITCHBOARD_SETTINGS_SIDEBAR_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW, SwitchboardSettingsSidebarRowClass))

typedef struct _SwitchboardSettingsSidebarRow SwitchboardSettingsSidebarRow;
typedef struct _SwitchboardSettingsSidebarRowClass SwitchboardSettingsSidebarRowClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _SwitchboardSettingsSidebarPrivate {
	GtkListBox* listbox;
	GtkStack* _stack;
	gboolean _show_title_buttons;
};

static gint SwitchboardSettingsSidebar_private_offset;
static gpointer switchboard_settings_sidebar_parent_class = NULL;

static void switchboard_settings_sidebar_update_selection (SwitchboardSettingsSidebar* self);
VALA_EXTERN GType switchboard_settings_sidebar_row_get_type (void) G_GNUC_CONST ;
VALA_EXTERN SwitchboardSettingsPage* switchboard_settings_sidebar_row_get_page (SwitchboardSettingsSidebarRow* self);
static GtkWidget* switchboard_settings_sidebar_create_widget_func (SwitchboardSettingsSidebar* self,
                                                            GObject* object);
VALA_EXTERN SwitchboardSettingsSidebarRow* switchboard_settings_sidebar_row_new (SwitchboardSettingsPage* page);
VALA_EXTERN SwitchboardSettingsSidebarRow* switchboard_settings_sidebar_row_construct (GType object_type,
                                                                           SwitchboardSettingsPage* page);
static GObject * switchboard_settings_sidebar_constructor (GType type,
                                                    guint n_construct_properties,
                                                    GObjectConstructParam * construct_properties);
static GtkWidget* _switchboard_settings_sidebar_create_widget_func_gtk_list_box_create_widget_func (GObject* item,
                                                                                             gpointer self);
static void _switchboard_settings_sidebar___lambda5_ (SwitchboardSettingsSidebar* self,
                                               GtkListBoxRow* row);
static void __switchboard_settings_sidebar___lambda5__gtk_list_box_row_selected (GtkListBox* _sender,
                                                                          GtkListBoxRow* row,
                                                                          gpointer self);
static void _switchboard_settings_sidebar___lambda6_ (SwitchboardSettingsSidebar* self,
                                               GtkListBoxRow* row,
                                               GtkListBoxRow* before);
VALA_EXTERN const gchar* switchboard_settings_sidebar_row_get_header (SwitchboardSettingsSidebarRow* self);
static void __switchboard_settings_sidebar___lambda6__gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                                GtkListBoxRow* before,
                                                                                gpointer self);
static void _switchboard_settings_sidebar_update_selection_g_object_notify (GObject* _sender,
                                                                     GParamSpec* pspec,
                                                                     gpointer self);
static void switchboard_settings_sidebar_finalize (GObject * obj);
static GType switchboard_settings_sidebar_get_type_once (void);
static void _vala_switchboard_settings_sidebar_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec);
static void _vala_switchboard_settings_sidebar_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec);

static inline gpointer
switchboard_settings_sidebar_get_instance_private (SwitchboardSettingsSidebar* self)
{
	return G_STRUCT_MEMBER_P (self, SwitchboardSettingsSidebar_private_offset);
}

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

SwitchboardSettingsSidebar*
switchboard_settings_sidebar_new (GtkStack* stack)
{
	return switchboard_settings_sidebar_construct (SWITCHBOARD_TYPE_SETTINGS_SIDEBAR, stack);
}

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

static void
switchboard_settings_sidebar_update_selection (SwitchboardSettingsSidebar* self)
{
	g_return_if_fail (self != NULL);
	{
		GtkWidget* child = NULL;
		GtkListBox* _tmp0_;
		GtkWidget* _tmp1_;
		GtkWidget* _tmp2_;
		_tmp0_ = self->priv->listbox;
		_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
		_tmp2_ = _g_object_ref0 (_tmp1_);
		child = _tmp2_;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				GtkWidget* _tmp7_;
				GtkWidget* _tmp8_;
				if (!_tmp3_) {
					GtkWidget* _tmp4_;
					GtkWidget* _tmp5_;
					GtkWidget* _tmp6_;
					_tmp4_ = child;
					_tmp5_ = gtk_widget_get_next_sibling (_tmp4_);
					_tmp6_ = _g_object_ref0 (_tmp5_);
					_g_object_unref0 (child);
					child = _tmp6_;
				}
				_tmp3_ = FALSE;
				_tmp7_ = child;
				if (!(_tmp7_ != NULL)) {
					break;
				}
				_tmp8_ = child;
				if (SWITCHBOARD_IS_SETTINGS_SIDEBAR_ROW (_tmp8_)) {
					SwitchboardSettingsSidebarRow* row = NULL;
					GtkWidget* _tmp9_;
					SwitchboardSettingsSidebarRow* _tmp10_;
					SwitchboardSettingsSidebarRow* _tmp11_;
					SwitchboardSettingsPage* _tmp12_;
					SwitchboardSettingsPage* _tmp13_;
					GtkStack* _tmp14_;
					GtkWidget* _tmp15_;
					GtkWidget* _tmp16_;
					_tmp9_ = child;
					_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW, SwitchboardSettingsSidebarRow));
					row = _tmp10_;
					_tmp11_ = row;
					_tmp12_ = switchboard_settings_sidebar_row_get_page (_tmp11_);
					_tmp13_ = _tmp12_;
					_tmp14_ = self->priv->_stack;
					_tmp15_ = gtk_stack_get_visible_child (_tmp14_);
					_tmp16_ = _tmp15_;
					if (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_widget_get_type (), GtkWidget) == _tmp16_) {
						GtkListBox* _tmp17_;
						SwitchboardSettingsSidebarRow* _tmp18_;
						_tmp17_ = self->priv->listbox;
						_tmp18_ = row;
						gtk_list_box_select_row (_tmp17_, G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, gtk_list_box_row_get_type (), GtkListBoxRow));
						_g_object_unref0 (row);
						break;
					}
					_g_object_unref0 (row);
				}
			}
		}
		_g_object_unref0 (child);
	}
}

static GtkWidget*
switchboard_settings_sidebar_create_widget_func (SwitchboardSettingsSidebar* self,
                                                 GObject* object)
{
	GtkStackPage* stack_page = NULL;
	SwitchboardSettingsPage* page = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	SwitchboardSettingsSidebarRow* row = NULL;
	SwitchboardSettingsSidebarRow* _tmp2_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (object != NULL, NULL);
	stack_page = G_TYPE_CHECK_INSTANCE_CAST (object, gtk_stack_page_get_type (), GtkStackPage);
	_tmp0_ = gtk_stack_page_get_child (stack_page);
	_tmp1_ = _tmp0_;
	page = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, SWITCHBOARD_TYPE_SETTINGS_PAGE, SwitchboardSettingsPage);
	_tmp2_ = switchboard_settings_sidebar_row_new (page);
	g_object_ref_sink (_tmp2_);
	row = _tmp2_;
	result = (GtkWidget*) row;
	return result;
}

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

static void
switchboard_settings_sidebar_set_stack (SwitchboardSettingsSidebar* self,
                                        GtkStack* value)
{
	GtkStack* old_value;
	g_return_if_fail (self != NULL);
	old_value = switchboard_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, switchboard_settings_sidebar_properties[SWITCHBOARD_SETTINGS_SIDEBAR_STACK_PROPERTY]);
	}
}

gboolean
switchboard_settings_sidebar_get_show_title_buttons (SwitchboardSettingsSidebar* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_show_title_buttons;
	return result;
}

void
switchboard_settings_sidebar_set_show_title_buttons (SwitchboardSettingsSidebar* self,
                                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = switchboard_settings_sidebar_get_show_title_buttons (self);
	if (old_value != value) {
		self->priv->_show_title_buttons = value;
		g_object_notify_by_pspec ((GObject *) self, switchboard_settings_sidebar_properties[SWITCHBOARD_SETTINGS_SIDEBAR_SHOW_TITLE_BUTTONS_PROPERTY]);
	}
}

const gchar*
switchboard_settings_sidebar_get_visible_child_name (SwitchboardSettingsSidebar* 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_;
		SwitchboardSettingsPage* _tmp5_;
		SwitchboardSettingsPage* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp4_ = selected_row;
		_tmp5_ = switchboard_settings_sidebar_row_get_page (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW, SwitchboardSettingsSidebarRow));
		_tmp6_ = _tmp5_;
		_tmp7_ = switchboard_settings_page_get_title (_tmp6_);
		_tmp8_ = _tmp7_;
		result = _tmp8_;
		_g_object_unref0 (selected_row);
		return result;
	}
}

void
switchboard_settings_sidebar_set_visible_child_name (SwitchboardSettingsSidebar* 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_;
		SwitchboardSettingsPage* _tmp7_;
		SwitchboardSettingsPage* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		GtkWidget* _tmp13_;
		GtkWidget* _tmp14_;
		_tmp2_ = listbox_child;
		if (!(_tmp2_ != NULL)) {
			break;
		}
		_tmp3_ = listbox_child;
		if (!SWITCHBOARD_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_ = switchboard_settings_sidebar_row_get_page (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW, SwitchboardSettingsSidebarRow));
		_tmp8_ = _tmp7_;
		_tmp9_ = switchboard_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, switchboard_settings_sidebar_properties[SWITCHBOARD_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY]);
}

static GtkWidget*
_switchboard_settings_sidebar_create_widget_func_gtk_list_box_create_widget_func (GObject* item,
                                                                                  gpointer self)
{
	GtkWidget* result;
	result = switchboard_settings_sidebar_create_widget_func ((SwitchboardSettingsSidebar*) self, item);
	return result;
}

static void
_switchboard_settings_sidebar___lambda5_ (SwitchboardSettingsSidebar* self,
                                          GtkListBoxRow* row)
{
	GtkStack* _tmp0_;
	SwitchboardSettingsPage* _tmp1_;
	SwitchboardSettingsPage* _tmp2_;
	if (row == NULL) {
		return;
	}
	_tmp0_ = self->priv->_stack;
	_tmp1_ = switchboard_settings_sidebar_row_get_page (G_TYPE_CHECK_INSTANCE_CAST (row, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW, SwitchboardSettingsSidebarRow));
	_tmp2_ = _tmp1_;
	gtk_stack_set_visible_child (_tmp0_, (GtkWidget*) _tmp2_);
}

static void
__switchboard_settings_sidebar___lambda5__gtk_list_box_row_selected (GtkListBox* _sender,
                                                                     GtkListBoxRow* row,
                                                                     gpointer self)
{
	_switchboard_settings_sidebar___lambda5_ ((SwitchboardSettingsSidebar*) self, row);
}

static void
_switchboard_settings_sidebar___lambda6_ (SwitchboardSettingsSidebar* 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_ = switchboard_settings_sidebar_row_get_header (G_TYPE_CHECK_INSTANCE_CAST (row, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW, SwitchboardSettingsSidebarRow));
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	header = _tmp2_;
	_tmp3_ = header;
	if (_tmp3_ != NULL) {
		GtkLabel* label = NULL;
		const gchar* _tmp11_;
		GtkLabel* _tmp12_ = NULL;
		GtkLabel* _tmp13_;
		GtkLabel* _tmp14_;
		if (before != NULL) {
			gchar* before_header = NULL;
			const gchar* _tmp4_;
			const gchar* _tmp5_;
			gchar* _tmp6_;
			gboolean _tmp7_ = FALSE;
			const gchar* _tmp8_;
			_tmp4_ = switchboard_settings_sidebar_row_get_header (G_TYPE_CHECK_INSTANCE_CAST (before, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR_ROW, SwitchboardSettingsSidebarRow));
			_tmp5_ = _tmp4_;
			_tmp6_ = g_strdup (_tmp5_);
			before_header = _tmp6_;
			_tmp8_ = before_header;
			if (_tmp8_ != NULL) {
				const gchar* _tmp9_;
				const gchar* _tmp10_;
				_tmp9_ = before_header;
				_tmp10_ = header;
				_tmp7_ = g_strcmp0 (_tmp9_, _tmp10_) == 0;
			} else {
				_tmp7_ = FALSE;
			}
			if (_tmp7_) {
				_g_free0 (before_header);
				_g_free0 (header);
				return;
			}
			_g_free0 (before_header);
		}
		_tmp11_ = header;
		_tmp12_ = (GtkLabel*) gtk_label_new (_tmp11_);
		gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_START);
		gtk_label_set_xalign (_tmp12_, (gfloat) 0);
		g_object_ref_sink (_tmp12_);
		label = _tmp12_;
		_tmp13_ = label;
		gtk_widget_add_css_class ((GtkWidget*) _tmp13_, GRANITE_STYLE_CLASS_H4_LABEL);
		_tmp14_ = label;
		gtk_list_box_row_set_header (row, (GtkWidget*) _tmp14_);
		_g_object_unref0 (label);
	}
	_g_free0 (header);
}

static void
__switchboard_settings_sidebar___lambda6__gtk_list_box_update_header_func (GtkListBoxRow* row,
                                                                           GtkListBoxRow* before,
                                                                           gpointer self)
{
	_switchboard_settings_sidebar___lambda6_ ((SwitchboardSettingsSidebar*) self, row, before);
}

static void
_switchboard_settings_sidebar_update_selection_g_object_notify (GObject* _sender,
                                                                GParamSpec* pspec,
                                                                gpointer self)
{
	switchboard_settings_sidebar_update_selection ((SwitchboardSettingsSidebar*) self);
}

static GObject *
switchboard_settings_sidebar_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SwitchboardSettingsSidebar * self;
	GtkListBox* _tmp0_ = NULL;
	GtkListBox* _tmp1_;
	GtkStack* _tmp2_;
	GtkSelectionModel* _tmp3_;
	GtkSelectionModel* _tmp4_;
	GtkSelectionModel* _tmp5_;
	GtkScrolledWindow* scrolled = NULL;
	GtkListBox* _tmp6_;
	GtkWidget* _tmp7_;
	GtkScrolledWindow* _tmp8_ = NULL;
	AdwHeaderBar* headerbar = NULL;
	AdwHeaderBar* _tmp9_ = NULL;
	AdwToolbarView* toolbarview = NULL;
	GtkScrolledWindow* _tmp10_;
	GtkWidget* _tmp11_;
	AdwToolbarView* _tmp12_ = NULL;
	AdwToolbarView* _tmp13_;
	AdwHeaderBar* _tmp14_;
	AdwToolbarView* _tmp15_;
	GtkListBox* _tmp16_;
	GtkListBox* _tmp17_;
	GtkStack* _tmp18_;
	AdwToolbarView* _tmp19_;
	parent_class = G_OBJECT_CLASS (switchboard_settings_sidebar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR, SwitchboardSettingsSidebar);
	_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_ = self->priv->_stack;
	_tmp3_ = gtk_stack_get_pages (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_;
	gtk_list_box_bind_model (_tmp1_, (GListModel*) _tmp5_, _switchboard_settings_sidebar_create_widget_func_gtk_list_box_create_widget_func, g_object_ref (self), g_object_unref);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = self->priv->listbox;
	_tmp7_ = _g_object_ref0 ((GtkWidget*) _tmp6_);
	_tmp8_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_set (_tmp8_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_scrolled_window_set_child (_tmp8_, _tmp7_);
	_g_object_unref0 (_tmp7_);
	g_object_ref_sink (_tmp8_);
	scrolled = _tmp8_;
	_tmp9_ = (AdwHeaderBar*) adw_header_bar_new ();
	adw_header_bar_set_show_end_title_buttons (_tmp9_, FALSE);
	adw_header_bar_set_show_title (_tmp9_, FALSE);
	g_object_ref_sink (_tmp9_);
	headerbar = _tmp9_;
	_tmp10_ = scrolled;
	_tmp11_ = _g_object_ref0 ((GtkWidget*) _tmp10_);
	_tmp12_ = (AdwToolbarView*) adw_toolbar_view_new ();
	adw_toolbar_view_set_content (_tmp12_, _tmp11_);
	_g_object_unref0 (_tmp11_);
	adw_toolbar_view_set_top_bar_style (_tmp12_, ADW_TOOLBAR_FLAT);
	g_object_ref_sink (_tmp12_);
	toolbarview = _tmp12_;
	_tmp13_ = toolbarview;
	_tmp14_ = headerbar;
	adw_toolbar_view_add_top_bar (_tmp13_, (GtkWidget*) _tmp14_);
	_tmp15_ = toolbarview;
	gtk_widget_set_parent ((GtkWidget*) _tmp15_, (GtkWidget*) self);
	gtk_widget_add_css_class ((GtkWidget*) self, GRANITE_STYLE_CLASS_SIDEBAR);
	_tmp16_ = self->priv->listbox;
	g_signal_connect_object (_tmp16_, "row-selected", (GCallback) __switchboard_settings_sidebar___lambda5__gtk_list_box_row_selected, self, 0);
	_tmp17_ = self->priv->listbox;
	gtk_list_box_set_header_func (_tmp17_, __switchboard_settings_sidebar___lambda6__gtk_list_box_update_header_func, g_object_ref (self), g_object_unref);
	_tmp18_ = self->priv->_stack;
	g_signal_connect_object ((GObject*) _tmp18_, "notify::visible-child", (GCallback) _switchboard_settings_sidebar_update_selection_g_object_notify, self, 0);
	_tmp19_ = toolbarview;
	g_object_bind_property_with_closures ((GObject*) self, "show-title-buttons", (GObject*) _tmp19_, "reveal-top-bars", G_BINDING_SYNC_CREATE, (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 (toolbarview);
	_g_object_unref0 (headerbar);
	_g_object_unref0 (scrolled);
	return obj;
}

static void
switchboard_settings_sidebar_base_init (SwitchboardSettingsSidebarClass * klass)
{
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "settingssidebar");
}

static void
switchboard_settings_sidebar_class_init (SwitchboardSettingsSidebarClass * klass,
                                         gpointer klass_data)
{
	switchboard_settings_sidebar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SwitchboardSettingsSidebar_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_switchboard_settings_sidebar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_switchboard_settings_sidebar_set_property;
	G_OBJECT_CLASS (klass)->constructor = switchboard_settings_sidebar_constructor;
	G_OBJECT_CLASS (klass)->finalize = switchboard_settings_sidebar_finalize;
	/**
	     * The Gtk.Stack to control
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWITCHBOARD_SETTINGS_SIDEBAR_STACK_PROPERTY, switchboard_settings_sidebar_properties[SWITCHBOARD_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));
	/**
	     * Whether to show back and title buttons in the header area
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWITCHBOARD_SETTINGS_SIDEBAR_SHOW_TITLE_BUTTONS_PROPERTY, switchboard_settings_sidebar_properties[SWITCHBOARD_SETTINGS_SIDEBAR_SHOW_TITLE_BUTTONS_PROPERTY] = g_param_spec_boolean ("show-title-buttons", "show-title-buttons", "show-title-buttons", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * The name of the currently visible Granite.SettingsPage
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWITCHBOARD_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY, switchboard_settings_sidebar_properties[SWITCHBOARD_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
switchboard_settings_sidebar_instance_init (SwitchboardSettingsSidebar * self,
                                            gpointer klass)
{
	self->priv = switchboard_settings_sidebar_get_instance_private (self);
}

static void
switchboard_settings_sidebar_finalize (GObject * obj)
{
	SwitchboardSettingsSidebar * self;
	GtkWidget* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR, SwitchboardSettingsSidebar);
	_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 (switchboard_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
switchboard_settings_sidebar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SwitchboardSettingsSidebarClass), (GBaseInitFunc) switchboard_settings_sidebar_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) switchboard_settings_sidebar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwitchboardSettingsSidebar), 0, (GInstanceInitFunc) switchboard_settings_sidebar_instance_init, NULL };
	GType switchboard_settings_sidebar_type_id;
	switchboard_settings_sidebar_type_id = g_type_register_static (gtk_widget_get_type (), "SwitchboardSettingsSidebar", &g_define_type_info, 0);
	SwitchboardSettingsSidebar_private_offset = g_type_add_instance_private (switchboard_settings_sidebar_type_id, sizeof (SwitchboardSettingsSidebarPrivate));
	return switchboard_settings_sidebar_type_id;
}

GType
switchboard_settings_sidebar_get_type (void)
{
	static volatile gsize switchboard_settings_sidebar_type_id__once = 0;
	if (g_once_init_enter (&switchboard_settings_sidebar_type_id__once)) {
		GType switchboard_settings_sidebar_type_id;
		switchboard_settings_sidebar_type_id = switchboard_settings_sidebar_get_type_once ();
		g_once_init_leave (&switchboard_settings_sidebar_type_id__once, switchboard_settings_sidebar_type_id);
	}
	return switchboard_settings_sidebar_type_id__once;
}

static void
_vala_switchboard_settings_sidebar_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec)
{
	SwitchboardSettingsSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR, SwitchboardSettingsSidebar);
	switch (property_id) {
		case SWITCHBOARD_SETTINGS_SIDEBAR_STACK_PROPERTY:
		g_value_set_object (value, switchboard_settings_sidebar_get_stack (self));
		break;
		case SWITCHBOARD_SETTINGS_SIDEBAR_SHOW_TITLE_BUTTONS_PROPERTY:
		g_value_set_boolean (value, switchboard_settings_sidebar_get_show_title_buttons (self));
		break;
		case SWITCHBOARD_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY:
		g_value_set_string (value, switchboard_settings_sidebar_get_visible_child_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_switchboard_settings_sidebar_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec)
{
	SwitchboardSettingsSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SWITCHBOARD_TYPE_SETTINGS_SIDEBAR, SwitchboardSettingsSidebar);
	switch (property_id) {
		case SWITCHBOARD_SETTINGS_SIDEBAR_STACK_PROPERTY:
		switchboard_settings_sidebar_set_stack (self, g_value_get_object (value));
		break;
		case SWITCHBOARD_SETTINGS_SIDEBAR_SHOW_TITLE_BUTTONS_PROPERTY:
		switchboard_settings_sidebar_set_show_title_buttons (self, g_value_get_boolean (value));
		break;
		case SWITCHBOARD_SETTINGS_SIDEBAR_VISIBLE_CHILD_NAME_PROPERTY:
		switchboard_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;
	}
}

