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

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

#include "ft_ui.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <string.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_PREFERENCES_SIDEBAR_0_PROPERTY,
	FT_PREFERENCES_SIDEBAR_MODEL_PROPERTY,
	FT_PREFERENCES_SIDEBAR_SELECTION_MODE_PROPERTY,
	FT_PREFERENCES_SIDEBAR_NUM_PROPERTIES
};
static GParamSpec* ft_preferences_sidebar_properties[FT_PREFERENCES_SIDEBAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _FtPreferencesSidebarPrivate {
	GtkSingleSelection* _model;
	GtkListBox* list;
	gulong row_selected_id;
};

static gint FtPreferencesSidebar_private_offset;
static gpointer ft_preferences_sidebar_parent_class = NULL;

static void ft_preferences_sidebar_add_row (FtPreferencesSidebar* self,
                                     guint position);
static void ft_preferences_sidebar_clear (FtPreferencesSidebar* self);
static void ft_preferences_sidebar_populate (FtPreferencesSidebar* self);
static void ft_preferences_sidebar_on_row_selected (FtPreferencesSidebar* self,
                                             GtkListBoxRow* row);
static void ft_preferences_sidebar_on_row_activated (FtPreferencesSidebar* self,
                                              GtkListBoxRow* row);
static void ft_preferences_sidebar_on_model_items_changed (FtPreferencesSidebar* self,
                                                    guint position,
                                                    guint removed,
                                                    guint added);
static void ft_preferences_sidebar_on_selection_changed (FtPreferencesSidebar* self,
                                                  guint position,
                                                  guint n_items);
static void ft_preferences_sidebar_real_dispose (GObject* base);
static void _ft_preferences_sidebar_on_model_items_changed_g_list_model_items_changed (GListModel* _sender,
                                                                                guint position,
                                                                                guint removed,
                                                                                guint added,
                                                                                gpointer self);
static void _ft_preferences_sidebar_on_selection_changed_gtk_selection_model_selection_changed (GtkSelectionModel* _sender,
                                                                                         guint position,
                                                                                         guint n_items,
                                                                                         gpointer self);
static void _ft_preferences_sidebar_on_row_selected_gtk_list_box_row_selected (GtkListBox* _sender,
                                                                        GtkListBoxRow* row,
                                                                        gpointer self);
static void _ft_preferences_sidebar_on_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                          GtkListBoxRow* row,
                                                                          gpointer self);
static GObject * ft_preferences_sidebar_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void ft_preferences_sidebar_finalize (GObject * obj);
static GType ft_preferences_sidebar_get_type_once (void);
static void _vala_ft_preferences_sidebar_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_ft_preferences_sidebar_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_preferences_sidebar_get_instance_private (FtPreferencesSidebar* self)
{
	return G_STRUCT_MEMBER_P (self, FtPreferencesSidebar_private_offset);
}

static void
ft_preferences_sidebar_add_row (FtPreferencesSidebar* self,
                                guint position)
{
	GtkImage* icon = NULL;
	GtkImage* _tmp0_;
	GtkLabel* label = NULL;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkBox* hbox = NULL;
	GtkBox* _tmp4_;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	GtkImage* _tmp10_;
	GtkBox* _tmp11_;
	GtkLabel* _tmp12_;
	GtkListBoxRow* row = NULL;
	GtkListBoxRow* _tmp13_;
	GtkListBoxRow* _tmp14_;
	GtkBox* _tmp15_;
	GtkListBoxRow* _tmp16_;
	GtkLabel* _tmp17_;
	GtkListBoxRow* _tmp18_;
	GObject* panel_info = NULL;
	GtkSingleSelection* _tmp19_;
	GObject* _tmp20_;
	GObject* _tmp21_;
	GtkLabel* _tmp22_;
	GObject* _tmp23_;
	GtkImage* _tmp24_;
	GObject* _tmp25_;
	GtkListBoxRow* _tmp26_;
	GtkListBox* _tmp27_;
	GtkListBoxRow* _tmp28_;
	GtkSingleSelection* _tmp29_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp0_);
	icon = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp1_);
	label = _tmp1_;
	_tmp2_ = label;
	gtk_widget_set_halign ((GtkWidget*) _tmp2_, GTK_ALIGN_START);
	_tmp3_ = label;
	gtk_widget_set_valign ((GtkWidget*) _tmp3_, GTK_ALIGN_CENTER);
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
	g_object_ref_sink (_tmp4_);
	hbox = _tmp4_;
	_tmp5_ = hbox;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp5_, 6);
	_tmp6_ = hbox;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp6_, 6);
	_tmp7_ = hbox;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp7_, 12);
	_tmp8_ = hbox;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp8_, 12);
	_tmp9_ = hbox;
	_tmp10_ = icon;
	gtk_box_append (_tmp9_, (GtkWidget*) _tmp10_);
	_tmp11_ = hbox;
	_tmp12_ = label;
	gtk_box_append (_tmp11_, (GtkWidget*) _tmp12_);
	_tmp13_ = (GtkListBoxRow*) gtk_list_box_row_new ();
	g_object_ref_sink (_tmp13_);
	row = _tmp13_;
	_tmp14_ = row;
	_tmp15_ = hbox;
	gtk_list_box_row_set_child (_tmp14_, (GtkWidget*) _tmp15_);
	_tmp16_ = row;
	_tmp17_ = label;
	gtk_accessible_update_relation ((GtkAccessible*) _tmp16_, GTK_ACCESSIBLE_RELATION_LABELLED_BY, _tmp17_, NULL, -1, -1);
	_tmp18_ = row;
	g_object_set_data_full ((GObject*) _tmp18_, "child-index", (gpointer) ((guintptr) position), NULL);
	_tmp19_ = self->priv->_model;
	_tmp20_ = g_list_model_get_item ((GListModel*) _tmp19_, position);
	panel_info = _tmp20_;
	_tmp21_ = panel_info;
	_tmp22_ = label;
	g_object_bind_property_with_closures (_tmp21_, "title", (GObject*) _tmp22_, "label", 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)));
	_tmp23_ = panel_info;
	_tmp24_ = icon;
	g_object_bind_property_with_closures (_tmp23_, "icon-name", (GObject*) _tmp24_, "icon-name", 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)));
	_tmp25_ = panel_info;
	_tmp26_ = row;
	g_object_bind_property_with_closures (_tmp25_, "visible", (GObject*) _tmp26_, "visible", 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)));
	_tmp27_ = self->priv->list;
	_tmp28_ = row;
	gtk_list_box_append (_tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = self->priv->_model;
	if (gtk_selection_model_is_selected ((GtkSelectionModel*) _tmp29_, position)) {
		GtkListBox* _tmp30_;
		GtkListBoxRow* _tmp31_;
		_tmp30_ = self->priv->list;
		_tmp31_ = row;
		gtk_list_box_select_row (_tmp30_, _tmp31_);
	} else {
		GtkListBox* _tmp32_;
		GtkListBoxRow* _tmp33_;
		_tmp32_ = self->priv->list;
		_tmp33_ = row;
		gtk_list_box_unselect_row (_tmp32_, _tmp33_);
	}
	_g_object_unref0 (panel_info);
	_g_object_unref0 (row);
	_g_object_unref0 (hbox);
	_g_object_unref0 (label);
	_g_object_unref0 (icon);
}

static void
ft_preferences_sidebar_clear (FtPreferencesSidebar* self)
{
	GtkListBox* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->list;
	gtk_list_box_remove_all (_tmp0_);
}

static void
ft_preferences_sidebar_populate (FtPreferencesSidebar* self)
{
	guint n_items = 0U;
	GtkSingleSelection* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_model;
	n_items = g_list_model_get_n_items ((GListModel*) _tmp0_);
	{
		gint position = 0;
		position = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = position;
					position = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(((guint) position) < n_items)) {
					break;
				}
				ft_preferences_sidebar_add_row (self, (guint) position);
			}
		}
	}
}

static void
ft_preferences_sidebar_on_row_selected (FtPreferencesSidebar* self,
                                        GtkListBoxRow* row)
{
	guint position = 0U;
	gconstpointer _tmp0_;
	GtkSingleSelection* _tmp1_;
	g_return_if_fail (self != NULL);
	if (row == NULL) {
		return;
	}
	_tmp0_ = g_object_get_data ((GObject*) row, "child-index");
	position = (guint) ((guintptr) _tmp0_);
	_tmp1_ = self->priv->_model;
	gtk_selection_model_select_item ((GtkSelectionModel*) _tmp1_, position, TRUE);
}

static void
ft_preferences_sidebar_on_row_activated (FtPreferencesSidebar* self,
                                         GtkListBoxRow* row)
{
	guint position = 0U;
	gconstpointer _tmp0_;
	GtkSelectionMode _tmp1_;
	GtkSelectionMode _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_object_get_data ((GObject*) row, "child-index");
	position = (guint) ((guintptr) _tmp0_);
	_tmp1_ = ft_preferences_sidebar_get_selection_mode (self);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == GTK_SELECTION_NONE) {
		GtkSingleSelection* _tmp3_;
		_tmp3_ = self->priv->_model;
		gtk_single_selection_set_selected (_tmp3_, position);
	}
}

static void
ft_preferences_sidebar_on_model_items_changed (FtPreferencesSidebar* self,
                                               guint position,
                                               guint removed,
                                               guint added)
{
	g_return_if_fail (self != NULL);
	ft_preferences_sidebar_clear (self);
	ft_preferences_sidebar_populate (self);
}

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

static void
ft_preferences_sidebar_on_selection_changed (FtPreferencesSidebar* self,
                                             guint position,
                                             guint n_items)
{
	GtkListBox* _tmp0_;
	GtkListBox* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->list;
	g_signal_handler_block (_tmp0_, self->priv->row_selected_id);
	{
		guint i = 0U;
		i = position;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GtkListBoxRow* row = NULL;
				GtkListBox* _tmp3_;
				GtkListBoxRow* _tmp4_;
				GtkListBoxRow* _tmp5_;
				GtkListBoxRow* _tmp6_;
				if (!_tmp1_) {
					guint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < (position + n_items))) {
					break;
				}
				_tmp3_ = self->priv->list;
				_tmp4_ = gtk_list_box_get_row_at_index (_tmp3_, (gint) i);
				_tmp5_ = _g_object_ref0 (_tmp4_);
				row = _tmp5_;
				_tmp6_ = row;
				if (_tmp6_ != NULL) {
					GtkSingleSelection* _tmp7_;
					_tmp7_ = self->priv->_model;
					if (gtk_selection_model_is_selected ((GtkSelectionModel*) _tmp7_, i)) {
						GtkListBox* _tmp8_;
						GtkListBoxRow* _tmp9_;
						_tmp8_ = self->priv->list;
						_tmp9_ = row;
						gtk_list_box_select_row (_tmp8_, _tmp9_);
					} else {
						GtkListBox* _tmp10_;
						GtkListBoxRow* _tmp11_;
						_tmp10_ = self->priv->list;
						_tmp11_ = row;
						gtk_list_box_unselect_row (_tmp10_, _tmp11_);
					}
				}
				_g_object_unref0 (row);
			}
		}
	}
	_tmp12_ = self->priv->list;
	g_signal_handler_unblock (_tmp12_, self->priv->row_selected_id);
}

static void
_ft_preferences_sidebar_on_model_items_changed_g_list_model_items_changed (GListModel* _sender,
                                                                           guint position,
                                                                           guint removed,
                                                                           guint added,
                                                                           gpointer self)
{
	ft_preferences_sidebar_on_model_items_changed ((FtPreferencesSidebar*) self, position, removed, added);
}

static void
_ft_preferences_sidebar_on_selection_changed_gtk_selection_model_selection_changed (GtkSelectionModel* _sender,
                                                                                    guint position,
                                                                                    guint n_items,
                                                                                    gpointer self)
{
	ft_preferences_sidebar_on_selection_changed ((FtPreferencesSidebar*) self, position, n_items);
}

static void
_ft_preferences_sidebar_on_row_selected_gtk_list_box_row_selected (GtkListBox* _sender,
                                                                   GtkListBoxRow* row,
                                                                   gpointer self)
{
	ft_preferences_sidebar_on_row_selected ((FtPreferencesSidebar*) self, row);
}

static void
_ft_preferences_sidebar_on_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                     GtkListBoxRow* row,
                                                                     gpointer self)
{
	ft_preferences_sidebar_on_row_activated ((FtPreferencesSidebar*) self, row);
}

static void
ft_preferences_sidebar_real_dispose (GObject* base)
{
	FtPreferencesSidebar * self;
	GtkSingleSelection* _tmp0_;
	GtkListBox* _tmp5_;
	GtkWidget* child = NULL;
	GtkWidget* _tmp10_;
	GtkWidget* _tmp11_;
	GtkWidget* _tmp12_;
	self = (FtPreferencesSidebar*) base;
	_tmp0_ = self->priv->_model;
	if (_tmp0_ != NULL) {
		GtkSingleSelection* _tmp1_;
		guint _tmp2_;
		GtkSingleSelection* _tmp3_;
		guint _tmp4_;
		_tmp1_ = self->priv->_model;
		g_signal_parse_name ("items-changed", g_list_model_get_type (), &_tmp2_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GListModel*) _tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _ft_preferences_sidebar_on_model_items_changed_g_list_model_items_changed, self);
		_tmp3_ = self->priv->_model;
		g_signal_parse_name ("selection-changed", gtk_selection_model_get_type (), &_tmp4_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkSelectionModel*) _tmp3_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _ft_preferences_sidebar_on_selection_changed_gtk_selection_model_selection_changed, self);
		_g_object_unref0 (self->priv->_model);
		self->priv->_model = NULL;
	}
	_tmp5_ = self->priv->list;
	if (_tmp5_ != NULL) {
		GtkListBox* _tmp6_;
		guint _tmp7_;
		GtkListBox* _tmp8_;
		guint _tmp9_;
		ft_preferences_sidebar_clear (self);
		_tmp6_ = self->priv->list;
		g_signal_parse_name ("row-selected", gtk_list_box_get_type (), &_tmp7_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _ft_preferences_sidebar_on_row_selected_gtk_list_box_row_selected, self);
		_tmp8_ = self->priv->list;
		g_signal_parse_name ("row-activated", gtk_list_box_get_type (), &_tmp9_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp8_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp9_, 0, NULL, (GCallback) _ft_preferences_sidebar_on_row_activated_gtk_list_box_row_activated, self);
		_g_object_unref0 (self->priv->list);
		self->priv->list = NULL;
	}
	_tmp10_ = gtk_widget_get_first_child ((GtkWidget*) self);
	_tmp11_ = _g_object_ref0 (_tmp10_);
	child = _tmp11_;
	_tmp12_ = child;
	if (_tmp12_ != NULL) {
		GtkWidget* _tmp13_;
		_tmp13_ = child;
		gtk_widget_unparent (_tmp13_);
	}
	G_OBJECT_CLASS (ft_preferences_sidebar_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (child);
}

FtPreferencesSidebar*
ft_preferences_sidebar_construct (GType object_type)
{
	FtPreferencesSidebar * self = NULL;
	self = (FtPreferencesSidebar*) g_object_new (object_type, NULL);
	return self;
}

FtPreferencesSidebar*
ft_preferences_sidebar_new (void)
{
	return ft_preferences_sidebar_construct (FT_TYPE_PREFERENCES_SIDEBAR);
}

GtkSingleSelection*
ft_preferences_sidebar_get_model (FtPreferencesSidebar* self)
{
	GtkSingleSelection* result;
	GtkSingleSelection* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_model;
	result = _tmp0_;
	return result;
}

void
ft_preferences_sidebar_set_model (FtPreferencesSidebar* self,
                                  GtkSingleSelection* value)
{
	GtkSingleSelection* _tmp0_;
	GtkSingleSelection* _tmp1_;
	GtkSingleSelection* _tmp6_;
	GtkSingleSelection* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_model;
	if (_tmp0_ == value) {
		return;
	}
	_tmp1_ = self->priv->_model;
	if (_tmp1_ != NULL) {
		GtkSingleSelection* _tmp2_;
		guint _tmp3_;
		GtkSingleSelection* _tmp4_;
		guint _tmp5_;
		_tmp2_ = self->priv->_model;
		g_signal_parse_name ("items-changed", g_list_model_get_type (), &_tmp3_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GListModel*) _tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _ft_preferences_sidebar_on_model_items_changed_g_list_model_items_changed, self);
		_tmp4_ = self->priv->_model;
		g_signal_parse_name ("selection-changed", gtk_selection_model_get_type (), &_tmp5_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkSelectionModel*) _tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _ft_preferences_sidebar_on_selection_changed_gtk_selection_model_selection_changed, self);
	}
	ft_preferences_sidebar_clear (self);
	_tmp6_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_model);
	self->priv->_model = _tmp6_;
	ft_preferences_sidebar_populate (self);
	_tmp7_ = self->priv->_model;
	if (_tmp7_ != NULL) {
		GtkSingleSelection* _tmp8_;
		GtkSingleSelection* _tmp9_;
		_tmp8_ = self->priv->_model;
		g_signal_connect_object ((GListModel*) _tmp8_, "items-changed", (GCallback) _ft_preferences_sidebar_on_model_items_changed_g_list_model_items_changed, self, 0);
		_tmp9_ = self->priv->_model;
		g_signal_connect_object ((GtkSelectionModel*) _tmp9_, "selection-changed", (GCallback) _ft_preferences_sidebar_on_selection_changed_gtk_selection_model_selection_changed, self, 0);
	}
	g_object_notify ((GObject*) self, "model");
	g_object_notify_by_pspec ((GObject *) self, ft_preferences_sidebar_properties[FT_PREFERENCES_SIDEBAR_MODEL_PROPERTY]);
}

GtkSelectionMode
ft_preferences_sidebar_get_selection_mode (FtPreferencesSidebar* self)
{
	GtkSelectionMode result;
	GtkListBox* _tmp0_;
	GtkSelectionMode _tmp1_;
	GtkSelectionMode _tmp2_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->list;
	_tmp1_ = gtk_list_box_get_selection_mode (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
ft_preferences_sidebar_set_selection_mode (FtPreferencesSidebar* self,
                                           GtkSelectionMode value)
{
	GtkListBox* _tmp0_;
	GtkListBox* _tmp1_;
	GtkSelectionMode _tmp2_;
	GtkSelectionMode _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->list;
	gtk_list_box_set_selection_mode (_tmp0_, value);
	_tmp1_ = self->priv->list;
	_tmp2_ = gtk_list_box_get_selection_mode (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ != GTK_SELECTION_NONE) {
		GtkListBoxRow* active_row = NULL;
		GtkListBox* _tmp4_;
		GtkSingleSelection* _tmp5_;
		guint _tmp6_;
		guint _tmp7_;
		GtkListBoxRow* _tmp8_;
		GtkListBoxRow* _tmp9_;
		GtkListBox* _tmp10_;
		GtkListBoxRow* _tmp11_;
		_tmp4_ = self->priv->list;
		_tmp5_ = self->priv->_model;
		_tmp6_ = gtk_single_selection_get_selected (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = gtk_list_box_get_row_at_index (_tmp4_, (gint) _tmp7_);
		_tmp9_ = _g_object_ref0 (_tmp8_);
		active_row = _tmp9_;
		_tmp10_ = self->priv->list;
		_tmp11_ = active_row;
		gtk_list_box_select_row (_tmp10_, _tmp11_);
		_g_object_unref0 (active_row);
	}
	g_object_notify_by_pspec ((GObject *) self, ft_preferences_sidebar_properties[FT_PREFERENCES_SIDEBAR_SELECTION_MODE_PROPERTY]);
}

static GObject *
ft_preferences_sidebar_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtPreferencesSidebar * self;
	GtkBinLayout* _tmp0_;
	GtkScrolledWindow* scrolled_window = NULL;
	GtkScrolledWindow* _tmp1_;
	GtkScrolledWindow* _tmp2_;
	GtkScrolledWindow* _tmp3_;
	GtkListBox* _tmp4_;
	GtkListBox* _tmp5_;
	GtkListBox* _tmp6_;
	GtkScrolledWindow* _tmp7_;
	GtkListBox* _tmp8_;
	GtkListBox* _tmp9_;
	gulong _tmp10_;
	GtkListBox* _tmp11_;
	parent_class = G_OBJECT_CLASS (ft_preferences_sidebar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_PREFERENCES_SIDEBAR, FtPreferencesSidebar);
	_tmp0_ = (GtkBinLayout*) gtk_bin_layout_new ();
	gtk_widget_set_layout_manager ((GtkWidget*) self, (GtkLayoutManager*) _tmp0_);
	_tmp1_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp1_);
	scrolled_window = _tmp1_;
	_tmp2_ = scrolled_window;
	gtk_scrolled_window_set_policy (_tmp2_, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	_tmp3_ = scrolled_window;
	gtk_widget_set_parent ((GtkWidget*) _tmp3_, (GtkWidget*) self);
	_tmp4_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->list);
	self->priv->list = _tmp4_;
	_tmp5_ = self->priv->list;
	gtk_widget_add_css_class ((GtkWidget*) _tmp5_, "navigation-sidebar");
	_tmp6_ = self->priv->list;
	gtk_accessible_update_property ((GtkAccessible*) _tmp6_, GTK_ACCESSIBLE_PROPERTY_LABEL, C_ ("accessibility", "Sidebar"), -1, -1);
	_tmp7_ = scrolled_window;
	_tmp8_ = self->priv->list;
	gtk_scrolled_window_set_child (_tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = self->priv->list;
	_tmp10_ = g_signal_connect_object (_tmp9_, "row-selected", (GCallback) _ft_preferences_sidebar_on_row_selected_gtk_list_box_row_selected, self, 0);
	self->priv->row_selected_id = _tmp10_;
	_tmp11_ = self->priv->list;
	g_signal_connect_object (_tmp11_, "row-activated", (GCallback) _ft_preferences_sidebar_on_row_activated_gtk_list_box_row_activated, self, 0);
	gtk_widget_add_css_class ((GtkWidget*) self, "sidebar");
	_g_object_unref0 (scrolled_window);
	return obj;
}

static void
ft_preferences_sidebar_class_init (FtPreferencesSidebarClass * klass,
                                   gpointer klass_data)
{
	ft_preferences_sidebar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtPreferencesSidebar_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_preferences_sidebar_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_preferences_sidebar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_preferences_sidebar_set_property;
	G_OBJECT_CLASS (klass)->constructor = ft_preferences_sidebar_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_preferences_sidebar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_PREFERENCES_SIDEBAR_MODEL_PROPERTY, ft_preferences_sidebar_properties[FT_PREFERENCES_SIDEBAR_MODEL_PROPERTY] = g_param_spec_object ("model", "model", "model", gtk_single_selection_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_PREFERENCES_SIDEBAR_SELECTION_MODE_PROPERTY, ft_preferences_sidebar_properties[FT_PREFERENCES_SIDEBAR_SELECTION_MODE_PROPERTY] = g_param_spec_enum ("selection-mode", "selection-mode", "selection-mode", gtk_selection_mode_get_type (), 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
ft_preferences_sidebar_instance_init (FtPreferencesSidebar * self,
                                      gpointer klass)
{
	self->priv = ft_preferences_sidebar_get_instance_private (self);
}

static void
ft_preferences_sidebar_finalize (GObject * obj)
{
	FtPreferencesSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_PREFERENCES_SIDEBAR, FtPreferencesSidebar);
	_g_object_unref0 (self->priv->_model);
	_g_object_unref0 (self->priv->list);
	G_OBJECT_CLASS (ft_preferences_sidebar_parent_class)->finalize (obj);
}

static GType
ft_preferences_sidebar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtPreferencesSidebarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_preferences_sidebar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtPreferencesSidebar), 0, (GInstanceInitFunc) ft_preferences_sidebar_instance_init, NULL };
	GType ft_preferences_sidebar_type_id;
	ft_preferences_sidebar_type_id = g_type_register_static (gtk_widget_get_type (), "FtPreferencesSidebar", &g_define_type_info, 0);
	FtPreferencesSidebar_private_offset = g_type_add_instance_private (ft_preferences_sidebar_type_id, sizeof (FtPreferencesSidebarPrivate));
	return ft_preferences_sidebar_type_id;
}

GType
ft_preferences_sidebar_get_type (void)
{
	static volatile gsize ft_preferences_sidebar_type_id__once = 0;
	if (g_once_init_enter (&ft_preferences_sidebar_type_id__once)) {
		GType ft_preferences_sidebar_type_id;
		ft_preferences_sidebar_type_id = ft_preferences_sidebar_get_type_once ();
		g_once_init_leave (&ft_preferences_sidebar_type_id__once, ft_preferences_sidebar_type_id);
	}
	return ft_preferences_sidebar_type_id__once;
}

static void
_vala_ft_preferences_sidebar_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	FtPreferencesSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_PREFERENCES_SIDEBAR, FtPreferencesSidebar);
	switch (property_id) {
		case FT_PREFERENCES_SIDEBAR_MODEL_PROPERTY:
		g_value_set_object (value, ft_preferences_sidebar_get_model (self));
		break;
		case FT_PREFERENCES_SIDEBAR_SELECTION_MODE_PROPERTY:
		g_value_set_enum (value, ft_preferences_sidebar_get_selection_mode (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_preferences_sidebar_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	FtPreferencesSidebar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_PREFERENCES_SIDEBAR, FtPreferencesSidebar);
	switch (property_id) {
		case FT_PREFERENCES_SIDEBAR_MODEL_PROPERTY:
		ft_preferences_sidebar_set_model (self, g_value_get_object (value));
		break;
		case FT_PREFERENCES_SIDEBAR_SELECTION_MODE_PROPERTY:
		ft_preferences_sidebar_set_selection_mode (self, g_value_get_enum (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;
}

