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

/*
 * This file is part of gitg
 *
 * Copyright (C) 2012 - Jesse van den Kieboom
 *
 * gitg is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * gitg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gitg. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>
#include "libgitg-ext.h"
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include <float.h>
#include <math.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>

#define GITG_PREFERENCES_HISTORY_version VERSION
#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 GITG_TYPE_PREFERENCES_HISTORY (gitg_preferences_history_get_type ())
#define GITG_PREFERENCES_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_PREFERENCES_HISTORY, GitgPreferencesHistory))
#define GITG_PREFERENCES_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_PREFERENCES_HISTORY, GitgPreferencesHistoryClass))
#define GITG_IS_PREFERENCES_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_PREFERENCES_HISTORY))
#define GITG_IS_PREFERENCES_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_PREFERENCES_HISTORY))
#define GITG_PREFERENCES_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_PREFERENCES_HISTORY, GitgPreferencesHistoryClass))

typedef struct _GitgPreferencesHistory GitgPreferencesHistory;
typedef struct _GitgPreferencesHistoryClass GitgPreferencesHistoryClass;
typedef struct _GitgPreferencesHistoryPrivate GitgPreferencesHistoryPrivate;
enum  {
	GITG_PREFERENCES_HISTORY_0_PROPERTY,
	GITG_PREFERENCES_HISTORY_DEFAULT_SELECTION_PROPERTY,
	GITG_PREFERENCES_HISTORY_WIDGET_PROPERTY,
	GITG_PREFERENCES_HISTORY_ID_PROPERTY,
	GITG_PREFERENCES_HISTORY_DISPLAY_NAME_PROPERTY,
	GITG_PREFERENCES_HISTORY_NUM_PROPERTIES
};
static GParamSpec* gitg_preferences_history_properties[GITG_PREFERENCES_HISTORY_NUM_PROPERTIES];
typedef struct _Block52Data Block52Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GitgPreferencesHistory {
	GtkGrid parent_instance;
	GitgPreferencesHistoryPrivate * priv;
};

struct _GitgPreferencesHistoryClass {
	GtkGridClass parent_class;
};

struct _GitgPreferencesHistoryPrivate {
	gboolean d_block;
	GtkCheckButton* d_collapse_inactive_lanes_enabled;
	GtkAdjustment* d_adjustment_collapse;
	GtkScale* d_collapse_inactive_lanes;
	GtkCheckButton* d_topological_order;
	GtkCheckButton* d_mainline_head;
	GtkRadioButton* d_select_current_branch;
	GtkRadioButton* d_select_all_branches;
	GtkRadioButton* d_select_all_commits;
	GtkCheckButton* d_sort_references_by_activity;
	GtkCheckButton* d_show_upstream_with_branch;
	GtkRadioButton** d_select_buttons;
	gint d_select_buttons_length1;
	gint _d_select_buttons_size_;
	gchar** d_select_names;
	gint d_select_names_length1;
	gint _d_select_names_size_;
};

struct _Block52Data {
	int _ref_count_;
	GitgPreferencesHistory* self;
	GSettings* settings;
	gulong monsig;
};

static gint GitgPreferencesHistory_private_offset;
static gpointer gitg_preferences_history_parent_class = NULL;
static GitgExtPreferencesIface * gitg_preferences_history_gitg_ext_preferences_parent_iface = NULL;

VALA_EXTERN GType gitg_preferences_history_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GitgPreferencesHistory, g_object_unref)
static gint gitg_preferences_history_round_val (gdouble val);
static void gitg_preferences_history_update_collapse_inactive_lanes (GitgPreferencesHistory* self,
                                                              GSettings* settings);
VALA_EXTERN GitgPreferencesHistory* gitg_preferences_history_new (void);
VALA_EXTERN GitgPreferencesHistory* gitg_preferences_history_construct (GType object_type);
VALA_EXTERN const gchar* gitg_preferences_history_get_default_selection (GitgPreferencesHistory* self);
VALA_EXTERN void gitg_preferences_history_set_default_selection (GitgPreferencesHistory* self,
                                                     const gchar* value);
static GObject * gitg_preferences_history_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties);
static Block52Data* block52_data_ref (Block52Data* _data52_);
static void block52_data_unref (void * _userdata_);
static void _gitg_preferences_history___lambda142_ (Block52Data* _data52_,
                                             GtkAdjustment* adj);
static void __gitg_preferences_history___lambda142__gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                                                           gpointer self);
static void _gitg_preferences_history___lambda143_ (Block52Data* _data52_,
                                             GSettings* s,
                                             const gchar* k);
static void __gitg_preferences_history___lambda143__g_settings_changed (GSettings* _sender,
                                                                 const gchar* key,
                                                                 gpointer self);
static void _gitg_preferences_history___lambda144_ (Block52Data* _data52_,
                                             GtkWidget* w);
static void __gitg_preferences_history___lambda144__gtk_widget_destroy (GtkWidget* _sender,
                                                                 gpointer self);
static void _gitg_preferences_history______lambda145_ (GitgPreferencesHistory* self);
static void __gitg_preferences_history______lambda145__g_object_notify (GObject* _sender,
                                                                 GParamSpec* pspec,
                                                                 gpointer self);
static gboolean _gitg_preferences_history___lambda146_ (GValue* value,
                                                 GVariant* variant);
static gboolean __gitg_preferences_history___lambda146__gsettings_bind_get_mapping (GValue* value,
                                                                             GVariant* variant,
                                                                             void* user_data);
static GVariant* _gitg_preferences_history___lambda147_ (GValue* value,
                                                  const GVariantType* expected_type);
static GVariant* __gitg_preferences_history___lambda147__gsettings_bind_set_mapping (GValue* value,
                                                                              const GVariantType* expected_type,
                                                                              void* user_data);
static void gitg_preferences_history_finalize (GObject * obj);
static GType gitg_preferences_history_get_type_once (void);
static void _vala_gitg_preferences_history_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_gitg_preferences_history_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
gitg_preferences_history_get_instance_private (GitgPreferencesHistory* self)
{
	return G_STRUCT_MEMBER_P (self, GitgPreferencesHistory_private_offset);
}

static gint
gitg_preferences_history_round_val (gdouble val)
{
	gint ival = 0;
	gint result;
	ival = (gint) val;
	result = ival + ((gint) ((val - ival) > 0.5));
	return result;
}

static void
gitg_preferences_history_update_collapse_inactive_lanes (GitgPreferencesHistory* self,
                                                         GSettings* settings)
{
	gint val = 0;
	GtkScale* _tmp0_;
	gint nval = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (settings != NULL);
	_tmp0_ = self->priv->d_collapse_inactive_lanes;
	val = gitg_preferences_history_round_val (gtk_range_get_value ((GtkRange*) _tmp0_));
	nval = g_settings_get_int (settings, "collapse-inactive-lanes");
	if (val != nval) {
		GtkScale* _tmp1_;
		_tmp1_ = self->priv->d_collapse_inactive_lanes;
		gtk_range_set_value ((GtkRange*) _tmp1_, (gdouble) nval);
	}
}

GitgPreferencesHistory*
gitg_preferences_history_construct (GType object_type)
{
	GitgPreferencesHistory * self = NULL;
	self = (GitgPreferencesHistory*) g_object_new (object_type, NULL);
	return self;
}

GitgPreferencesHistory*
gitg_preferences_history_new (void)
{
	return gitg_preferences_history_construct (GITG_TYPE_PREFERENCES_HISTORY);
}

const gchar*
gitg_preferences_history_get_default_selection (GitgPreferencesHistory* self)
{
	const gchar* result;
	gchar** _tmp9_;
	gint _tmp9__length1;
	const gchar* _tmp10_;
	g_return_val_if_fail (self != NULL, NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GtkRadioButton** _tmp2_;
				gint _tmp2__length1;
				GtkRadioButton** _tmp3_;
				gint _tmp3__length1;
				GtkRadioButton* _tmp4_;
				gboolean _tmp5_;
				gboolean _tmp6_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->d_select_buttons;
				_tmp2__length1 = self->priv->d_select_buttons_length1;
				if (!(i < _tmp2__length1)) {
					break;
				}
				_tmp3_ = self->priv->d_select_buttons;
				_tmp3__length1 = self->priv->d_select_buttons_length1;
				_tmp4_ = _tmp3_[i];
				_tmp5_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp4_);
				_tmp6_ = _tmp5_;
				if (_tmp6_) {
					gchar** _tmp7_;
					gint _tmp7__length1;
					const gchar* _tmp8_;
					_tmp7_ = self->priv->d_select_names;
					_tmp7__length1 = self->priv->d_select_names_length1;
					_tmp8_ = _tmp7_[i];
					result = _tmp8_;
					return result;
				}
			}
		}
	}
	_tmp9_ = self->priv->d_select_names;
	_tmp9__length1 = self->priv->d_select_names_length1;
	_tmp10_ = _tmp9_[0];
	result = _tmp10_;
	return result;
}

void
gitg_preferences_history_set_default_selection (GitgPreferencesHistory* self,
                                                const gchar* value)
{
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GtkRadioButton** _tmp2_;
				gint _tmp2__length1;
				gchar** _tmp3_;
				gint _tmp3__length1;
				const gchar* _tmp4_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->d_select_buttons;
				_tmp2__length1 = self->priv->d_select_buttons_length1;
				if (!(i < _tmp2__length1)) {
					break;
				}
				_tmp3_ = self->priv->d_select_names;
				_tmp3__length1 = self->priv->d_select_names_length1;
				_tmp4_ = _tmp3_[i];
				if (g_strcmp0 (_tmp4_, value) == 0) {
					GtkRadioButton** _tmp5_;
					gint _tmp5__length1;
					GtkRadioButton* _tmp6_;
					_tmp5_ = self->priv->d_select_buttons;
					_tmp5__length1 = self->priv->d_select_buttons_length1;
					_tmp6_ = _tmp5_[i];
					gtk_toggle_button_set_active ((GtkToggleButton*) _tmp6_, TRUE);
					return;
				}
			}
		}
	}
	g_object_notify_by_pspec ((GObject *) self, gitg_preferences_history_properties[GITG_PREFERENCES_HISTORY_DEFAULT_SELECTION_PROPERTY]);
}

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

static GtkWidget*
gitg_preferences_history_real_get_widget (GitgExtPreferences* base)
{
	GtkWidget* result;
	GitgPreferencesHistory* self;
	GtkWidget* _tmp0_;
	self = (GitgPreferencesHistory*) base;
	_tmp0_ = _g_object_ref0 ((GtkWidget*) self);
	result = _tmp0_;
	return result;
}

static gchar*
gitg_preferences_history_real_get_id (GitgExtPreferences* base)
{
	gchar* result;
	GitgPreferencesHistory* self;
	gchar* _tmp0_;
	self = (GitgPreferencesHistory*) base;
	_tmp0_ = g_strdup ("/org/gnome/gitg/Preferences/History");
	result = _tmp0_;
	return result;
}

static gchar*
gitg_preferences_history_real_get_display_name (GitgExtPreferences* base)
{
	gchar* result;
	GitgPreferencesHistory* self;
	gchar* _tmp0_;
	self = (GitgPreferencesHistory*) base;
	_tmp0_ = g_strdup (_ ("History"));
	result = _tmp0_;
	return result;
}

static Block52Data*
block52_data_ref (Block52Data* _data52_)
{
	g_atomic_int_inc (&_data52_->_ref_count_);
	return _data52_;
}

static void
block52_data_unref (void * _userdata_)
{
	Block52Data* _data52_;
	_data52_ = (Block52Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data52_->_ref_count_)) {
		GitgPreferencesHistory* self;
		self = _data52_->self;
		_g_object_unref0 (_data52_->settings);
		_g_object_unref0 (self);
		g_slice_free (Block52Data, _data52_);
	}
}

static void
_gitg_preferences_history___lambda142_ (Block52Data* _data52_,
                                        GtkAdjustment* adj)
{
	GitgPreferencesHistory* self;
	gint nval = 0;
	gint val = 0;
	GSettings* _tmp0_;
	self = _data52_->self;
	g_return_if_fail (adj != NULL);
	if (self->priv->d_block) {
		return;
	}
	nval = gitg_preferences_history_round_val (gtk_adjustment_get_value (adj));
	_tmp0_ = _data52_->settings;
	val = g_settings_get_int (_tmp0_, "collapse-inactive-lanes");
	if (val != nval) {
		GSettings* _tmp1_;
		_tmp1_ = _data52_->settings;
		g_settings_set_int (_tmp1_, "collapse-inactive-lanes", nval);
	}
	self->priv->d_block = TRUE;
	gtk_adjustment_set_value (adj, (gdouble) nval);
	self->priv->d_block = FALSE;
}

static void
__gitg_preferences_history___lambda142__gtk_adjustment_value_changed (GtkAdjustment* _sender,
                                                                      gpointer self)
{
	_gitg_preferences_history___lambda142_ (self, _sender);
}

static void
_gitg_preferences_history___lambda143_ (Block52Data* _data52_,
                                        GSettings* s,
                                        const gchar* k)
{
	GitgPreferencesHistory* self;
	GSettings* _tmp0_;
	self = _data52_->self;
	g_return_if_fail (s != NULL);
	g_return_if_fail (k != NULL);
	self->priv->d_block = TRUE;
	_tmp0_ = _data52_->settings;
	gitg_preferences_history_update_collapse_inactive_lanes (self, _tmp0_);
	self->priv->d_block = FALSE;
}

static void
__gitg_preferences_history___lambda143__g_settings_changed (GSettings* _sender,
                                                            const gchar* key,
                                                            gpointer self)
{
	_gitg_preferences_history___lambda143_ (self, _sender, key);
}

static void
_gitg_preferences_history___lambda144_ (Block52Data* _data52_,
                                        GtkWidget* w)
{
	GitgPreferencesHistory* self;
	GSettings* _tmp0_;
	self = _data52_->self;
	g_return_if_fail (w != NULL);
	_tmp0_ = _data52_->settings;
	g_signal_handler_disconnect ((GObject*) _tmp0_, _data52_->monsig);
}

static void
__gitg_preferences_history___lambda144__gtk_widget_destroy (GtkWidget* _sender,
                                                            gpointer self)
{
	_gitg_preferences_history___lambda144_ (self, _sender);
}

static void
_gitg_preferences_history______lambda145_ (GitgPreferencesHistory* self)
{
	g_object_notify ((GObject*) self, "default-selection");
}

static void
__gitg_preferences_history______lambda145__g_object_notify (GObject* _sender,
                                                            GParamSpec* pspec,
                                                            gpointer self)
{
	_gitg_preferences_history______lambda145_ ((GitgPreferencesHistory*) self);
}

static gboolean
_gitg_preferences_history___lambda146_ (GValue* value,
                                        GVariant* variant)
{
	const gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (value != NULL, FALSE);
	g_return_val_if_fail (variant != NULL, FALSE);
	_tmp0_ = g_variant_get_string (variant, NULL);
	g_value_set_boolean (value, g_strcmp0 (_tmp0_, "last-activity") == 0);
	result = TRUE;
	return result;
}

static gboolean
__gitg_preferences_history___lambda146__gsettings_bind_get_mapping (GValue* value,
                                                                    GVariant* variant,
                                                                    void* user_data)
{
	gboolean result;
	result = _gitg_preferences_history___lambda146_ (value, variant);
	return result;
}

static GVariant*
_gitg_preferences_history___lambda147_ (GValue* value,
                                        const GVariantType* expected_type)
{
	const gchar* _tmp0_ = NULL;
	GVariant* _tmp1_;
	GVariant* result;
	g_return_val_if_fail (value != NULL, NULL);
	g_return_val_if_fail (expected_type != NULL, NULL);
	if (g_value_get_boolean (value)) {
		_tmp0_ = "last-activity";
	} else {
		_tmp0_ = "name";
	}
	_tmp1_ = g_variant_new_string (_tmp0_);
	g_variant_ref_sink (_tmp1_);
	result = _tmp1_;
	return result;
}

static GVariant*
__gitg_preferences_history___lambda147__gsettings_bind_set_mapping (GValue* value,
                                                                    const GVariantType* expected_type,
                                                                    void* user_data)
{
	GVariant* result;
	result = _gitg_preferences_history___lambda147_ (value, expected_type);
	return result;
}

static GObject *
gitg_preferences_history_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GitgPreferencesHistory * self;
	Block52Data* _data52_;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	GtkCheckButton* _tmp2_;
	GSettings* _tmp3_;
	GtkCheckButton* _tmp4_;
	GSettings* _tmp5_;
	GtkCheckButton* _tmp6_;
	GtkAdjustment* _tmp7_;
	GSettings* _tmp8_;
	gulong _tmp9_;
	GSettings* _tmp10_;
	GtkRadioButton* _tmp11_;
	GtkRadioButton* _tmp12_;
	GtkRadioButton* _tmp13_;
	GtkRadioButton* _tmp14_;
	GtkRadioButton* _tmp15_;
	GtkRadioButton* _tmp16_;
	GtkRadioButton** _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar** _tmp21_;
	GSettings* _tmp22_;
	GSettings* _tmp28_;
	GtkCheckButton* _tmp29_;
	GSettings* _tmp30_;
	GtkCheckButton* _tmp31_;
	parent_class = G_OBJECT_CLASS (gitg_preferences_history_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_PREFERENCES_HISTORY, GitgPreferencesHistory);
	_data52_ = g_slice_new0 (Block52Data);
	_data52_->_ref_count_ = 1;
	_data52_->self = g_object_ref (self);
	_tmp0_ = g_settings_new (APPLICATION_ID ".preferences.history");
	_data52_->settings = _tmp0_;
	_tmp1_ = _data52_->settings;
	_tmp2_ = self->priv->d_collapse_inactive_lanes_enabled;
	g_settings_bind (_tmp1_, "collapse-inactive-lanes-enabled", (GObject*) _tmp2_, "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
	_tmp3_ = _data52_->settings;
	_tmp4_ = self->priv->d_topological_order;
	g_settings_bind (_tmp3_, "topological-order", (GObject*) _tmp4_, "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
	_tmp5_ = _data52_->settings;
	_tmp6_ = self->priv->d_mainline_head;
	g_settings_bind (_tmp5_, "mainline-head", (GObject*) _tmp6_, "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
	_tmp7_ = self->priv->d_adjustment_collapse;
	g_signal_connect_data (_tmp7_, "value-changed", (GCallback) __gitg_preferences_history___lambda142__gtk_adjustment_value_changed, block52_data_ref (_data52_), (GClosureNotify) block52_data_unref, 0);
	_tmp8_ = _data52_->settings;
	_tmp9_ = g_signal_connect_data (_tmp8_, "changed::collapse-inactive-lanes", (GCallback) __gitg_preferences_history___lambda143__g_settings_changed, block52_data_ref (_data52_), (GClosureNotify) block52_data_unref, 0);
	_data52_->monsig = _tmp9_;
	g_signal_connect_data ((GtkWidget*) self, "destroy", (GCallback) __gitg_preferences_history___lambda144__gtk_widget_destroy, block52_data_ref (_data52_), (GClosureNotify) block52_data_unref, 0);
	_tmp10_ = _data52_->settings;
	gitg_preferences_history_update_collapse_inactive_lanes (self, _tmp10_);
	_tmp11_ = self->priv->d_select_current_branch;
	_tmp12_ = _g_object_ref0 (_tmp11_);
	_tmp13_ = self->priv->d_select_all_branches;
	_tmp14_ = _g_object_ref0 (_tmp13_);
	_tmp15_ = self->priv->d_select_all_commits;
	_tmp16_ = _g_object_ref0 (_tmp15_);
	_tmp17_ = g_new0 (GtkRadioButton*, 3 + 1);
	_tmp17_[0] = _tmp12_;
	_tmp17_[1] = _tmp14_;
	_tmp17_[2] = _tmp16_;
	self->priv->d_select_buttons = (_vala_array_free (self->priv->d_select_buttons, self->priv->d_select_buttons_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->d_select_buttons = _tmp17_;
	self->priv->d_select_buttons_length1 = 3;
	self->priv->_d_select_buttons_size_ = self->priv->d_select_buttons_length1;
	_tmp18_ = g_strdup ("current-branch");
	_tmp19_ = g_strdup ("all-branches");
	_tmp20_ = g_strdup ("all-commits");
	_tmp21_ = g_new0 (gchar*, 3 + 1);
	_tmp21_[0] = _tmp18_;
	_tmp21_[1] = _tmp19_;
	_tmp21_[2] = _tmp20_;
	self->priv->d_select_names = (_vala_array_free (self->priv->d_select_names, self->priv->d_select_names_length1, (GDestroyNotify) g_free), NULL);
	self->priv->d_select_names = _tmp21_;
	self->priv->d_select_names_length1 = 3;
	self->priv->_d_select_names_size_ = self->priv->d_select_names_length1;
	_tmp22_ = _data52_->settings;
	g_settings_bind (_tmp22_, "default-selection", (GObject*) self, "default-selection", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp23_ = FALSE;
			_tmp23_ = TRUE;
			while (TRUE) {
				GtkRadioButton** _tmp25_;
				gint _tmp25__length1;
				GtkRadioButton** _tmp26_;
				gint _tmp26__length1;
				GtkRadioButton* _tmp27_;
				if (!_tmp23_) {
					gint _tmp24_;
					_tmp24_ = i;
					i = _tmp24_ + 1;
				}
				_tmp23_ = FALSE;
				_tmp25_ = self->priv->d_select_buttons;
				_tmp25__length1 = self->priv->d_select_buttons_length1;
				if (!(i < _tmp25__length1)) {
					break;
				}
				_tmp26_ = self->priv->d_select_buttons;
				_tmp26__length1 = self->priv->d_select_buttons_length1;
				_tmp27_ = _tmp26_[i];
				g_signal_connect_object ((GObject*) _tmp27_, "notify::active", (GCallback) __gitg_preferences_history______lambda145__g_object_notify, self, 0);
			}
		}
	}
	_tmp28_ = _data52_->settings;
	_tmp29_ = self->priv->d_sort_references_by_activity;
	g_settings_bind_with_mapping (_tmp28_, "reference-sort-order", (GObject*) _tmp29_, "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET, __gitg_preferences_history___lambda146__gsettings_bind_get_mapping, __gitg_preferences_history___lambda147__gsettings_bind_set_mapping, NULL, NULL);
	_tmp30_ = _data52_->settings;
	_tmp31_ = self->priv->d_show_upstream_with_branch;
	g_settings_bind (_tmp30_, "show-upstream-with-branch", (GObject*) _tmp31_, "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
	block52_data_unref (_data52_);
	_data52_ = NULL;
	return obj;
}

static void
gitg_preferences_history_class_init (GitgPreferencesHistoryClass * klass,
                                     gpointer klass_data)
{
	gitg_preferences_history_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GitgPreferencesHistory_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gitg_preferences_history_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gitg_preferences_history_set_property;
	G_OBJECT_CLASS (klass)->constructor = gitg_preferences_history_constructor;
	G_OBJECT_CLASS (klass)->finalize = gitg_preferences_history_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PREFERENCES_HISTORY_DEFAULT_SELECTION_PROPERTY, gitg_preferences_history_properties[GITG_PREFERENCES_HISTORY_DEFAULT_SELECTION_PROPERTY] = g_param_spec_string ("default-selection", "default-selection", "default-selection", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PREFERENCES_HISTORY_WIDGET_PROPERTY, gitg_preferences_history_properties[GITG_PREFERENCES_HISTORY_WIDGET_PROPERTY] = g_param_spec_object ("widget", "widget", "widget", gtk_widget_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PREFERENCES_HISTORY_ID_PROPERTY, gitg_preferences_history_properties[GITG_PREFERENCES_HISTORY_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PREFERENCES_HISTORY_DISPLAY_NAME_PROPERTY, gitg_preferences_history_properties[GITG_PREFERENCES_HISTORY_DISPLAY_NAME_PROPERTY] = g_param_spec_string ("display-name", "display-name", "display-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/gitg/ui/gitg-preferences-history.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "collapse_inactive_lanes_enabled", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_collapse_inactive_lanes_enabled));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "adjustment_collapse", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_adjustment_collapse));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "collapse_inactive_lanes", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_collapse_inactive_lanes));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "topological_order", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_topological_order));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "mainline_head", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_mainline_head));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "select_current_branch", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_select_current_branch));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "select_all_branches", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_select_all_branches));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "select_all_commits", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_select_all_commits));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "sort_references_by_activity", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_sort_references_by_activity));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "show_upstream_with_branch", FALSE, GitgPreferencesHistory_private_offset + G_STRUCT_OFFSET (GitgPreferencesHistoryPrivate, d_show_upstream_with_branch));
}

static void
gitg_preferences_history_gitg_ext_preferences_interface_init (GitgExtPreferencesIface * iface,
                                                              gpointer iface_data)
{
	gitg_preferences_history_gitg_ext_preferences_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_widget = gitg_preferences_history_real_get_widget;
	iface->get_id = gitg_preferences_history_real_get_id;
	iface->get_display_name = gitg_preferences_history_real_get_display_name;
}

static void
gitg_preferences_history_instance_init (GitgPreferencesHistory * self,
                                        gpointer klass)
{
	self->priv = gitg_preferences_history_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
gitg_preferences_history_finalize (GObject * obj)
{
	GitgPreferencesHistory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_PREFERENCES_HISTORY, GitgPreferencesHistory);
	self->priv->d_select_buttons = (_vala_array_free (self->priv->d_select_buttons, self->priv->d_select_buttons_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->d_select_names = (_vala_array_free (self->priv->d_select_names, self->priv->d_select_names_length1, (GDestroyNotify) g_free), NULL);
	G_OBJECT_CLASS (gitg_preferences_history_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gitg_preferences_history_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GitgPreferencesHistoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_preferences_history_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgPreferencesHistory), 0, (GInstanceInitFunc) gitg_preferences_history_instance_init, NULL };
	static const GInterfaceInfo gitg_ext_preferences_info = { (GInterfaceInitFunc) gitg_preferences_history_gitg_ext_preferences_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gitg_preferences_history_type_id;
	gitg_preferences_history_type_id = g_type_register_static (gtk_grid_get_type (), "GitgPreferencesHistory", &g_define_type_info, 0);
	g_type_add_interface_static (gitg_preferences_history_type_id, GITG_EXT_TYPE_PREFERENCES, &gitg_ext_preferences_info);
	GitgPreferencesHistory_private_offset = g_type_add_instance_private (gitg_preferences_history_type_id, sizeof (GitgPreferencesHistoryPrivate));
	return gitg_preferences_history_type_id;
}

GType
gitg_preferences_history_get_type (void)
{
	static gsize gitg_preferences_history_type_id__once = 0;
	if (g_once_init_enter (&gitg_preferences_history_type_id__once)) {
		GType gitg_preferences_history_type_id;
		gitg_preferences_history_type_id = gitg_preferences_history_get_type_once ();
		g_once_init_leave (&gitg_preferences_history_type_id__once, gitg_preferences_history_type_id);
	}
	return gitg_preferences_history_type_id__once;
}

static void
_vala_gitg_preferences_history_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GitgPreferencesHistory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GITG_TYPE_PREFERENCES_HISTORY, GitgPreferencesHistory);
	switch (property_id) {
		case GITG_PREFERENCES_HISTORY_DEFAULT_SELECTION_PROPERTY:
		g_value_set_string (value, gitg_preferences_history_get_default_selection (self));
		break;
		case GITG_PREFERENCES_HISTORY_WIDGET_PROPERTY:
		g_value_take_object (value, gitg_ext_preferences_get_widget ((GitgExtPreferences*) self));
		break;
		case GITG_PREFERENCES_HISTORY_ID_PROPERTY:
		g_value_take_string (value, gitg_ext_preferences_get_id ((GitgExtPreferences*) self));
		break;
		case GITG_PREFERENCES_HISTORY_DISPLAY_NAME_PROPERTY:
		g_value_take_string (value, gitg_ext_preferences_get_display_name ((GitgExtPreferences*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gitg_preferences_history_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	GitgPreferencesHistory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GITG_TYPE_PREFERENCES_HISTORY, GitgPreferencesHistory);
	switch (property_id) {
		case GITG_PREFERENCES_HISTORY_DEFAULT_SELECTION_PROPERTY:
		gitg_preferences_history_set_default_selection (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

