/* ConfigLocationTable.c generated by valac 0.11.6, the Vala compiler
 * generated from ConfigLocationTable.vala, do not modify */

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
    This file is part of Déjà Dup.
    © 2010 Michael Terry <mike@mterry.name>

    Déjà Dup 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 3 of the License, or
    (at your option) any later version.

    Déjà Dup 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 Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>


#define DEJA_DUP_TYPE_CONFIG_LOCATION_TABLE (deja_dup_config_location_table_get_type ())
#define DEJA_DUP_CONFIG_LOCATION_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_CONFIG_LOCATION_TABLE, DejaDupConfigLocationTable))
#define DEJA_DUP_CONFIG_LOCATION_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_CONFIG_LOCATION_TABLE, DejaDupConfigLocationTableClass))
#define DEJA_DUP_IS_CONFIG_LOCATION_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_CONFIG_LOCATION_TABLE))
#define DEJA_DUP_IS_CONFIG_LOCATION_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_CONFIG_LOCATION_TABLE))
#define DEJA_DUP_CONFIG_LOCATION_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_CONFIG_LOCATION_TABLE, DejaDupConfigLocationTableClass))

typedef struct _DejaDupConfigLocationTable DejaDupConfigLocationTable;
typedef struct _DejaDupConfigLocationTableClass DejaDupConfigLocationTableClass;
typedef struct _DejaDupConfigLocationTablePrivate DejaDupConfigLocationTablePrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define DEJA_DUP_TYPE_TOGGLABLE (deja_dup_togglable_get_type ())
#define DEJA_DUP_TOGGLABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_TOGGLABLE, DejaDupTogglable))
#define DEJA_DUP_IS_TOGGLABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_TOGGLABLE))
#define DEJA_DUP_TOGGLABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), DEJA_DUP_TYPE_TOGGLABLE, DejaDupTogglableIface))

typedef struct _DejaDupTogglable DejaDupTogglable;
typedef struct _DejaDupTogglableIface DejaDupTogglableIface;
typedef struct _Block1Data Block1Data;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block2Data Block2Data;

struct _DejaDupConfigLocationTable {
	GtkTable parent_instance;
	DejaDupConfigLocationTablePrivate * priv;
	gint row;
};

struct _DejaDupConfigLocationTableClass {
	GtkTableClass parent_class;
};

struct _DejaDupConfigLocationTablePrivate {
	GtkSizeGroup* _label_sizes;
};

struct _DejaDupTogglableIface {
	GTypeInterface parent_iface;
	gboolean (*get_active) (DejaDupTogglable* self);
};

struct _Block1Data {
	int _ref_count_;
	DejaDupConfigLocationTable * self;
	GtkLabel* label;
	GtkWidget* w;
	DejaDupTogglable* check;
};

struct _Block2Data {
	int _ref_count_;
	DejaDupConfigLocationTable * self;
	GtkHBox* hbox;
	DejaDupTogglable* check;
};


static gpointer deja_dup_config_location_table_parent_class = NULL;

GType deja_dup_config_location_table_get_type (void) G_GNUC_CONST;
#define DEJA_DUP_CONFIG_LOCATION_TABLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEJA_DUP_TYPE_CONFIG_LOCATION_TABLE, DejaDupConfigLocationTablePrivate))
enum  {
	DEJA_DUP_CONFIG_LOCATION_TABLE_DUMMY_PROPERTY,
	DEJA_DUP_CONFIG_LOCATION_TABLE_LABEL_SIZES
};
DejaDupConfigLocationTable* deja_dup_config_location_table_new (GtkSizeGroup* sg);
DejaDupConfigLocationTable* deja_dup_config_location_table_construct (GType object_type, GtkSizeGroup* sg);
GType deja_dup_togglable_get_type (void) G_GNUC_CONST;
void deja_dup_config_location_table_add_widget (DejaDupConfigLocationTable* self, const gchar* msg, GtkWidget* w, DejaDupTogglable* check);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (Block1Data* _data1_);
GtkSizeGroup* deja_dup_config_location_table_get_label_sizes (DejaDupConfigLocationTable* self);
gboolean deja_dup_togglable_get_active (DejaDupTogglable* self);
static void _lambda1_ (Block1Data* _data1_);
static void __lambda1__deja_dup_togglable_toggled (DejaDupTogglable* _sender, DejaDupTogglable* t, gboolean user, gpointer self);
void deja_dup_config_location_table_add_wide_widget (DejaDupConfigLocationTable* self, GtkWidget* w, DejaDupTogglable* check);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (Block2Data* _data2_);
static void _lambda2_ (Block2Data* _data2_);
static void __lambda2__deja_dup_togglable_toggled (DejaDupTogglable* _sender, DejaDupTogglable* t, gboolean user, gpointer self);
void deja_dup_config_location_table_add_optional_label (DejaDupConfigLocationTable* self);
static void deja_dup_config_location_table_set_label_sizes (DejaDupConfigLocationTable* self, GtkSizeGroup* value);
static GObject * deja_dup_config_location_table_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void deja_dup_config_location_table_finalize (GObject* obj);
static void _vala_deja_dup_config_location_table_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_deja_dup_config_location_table_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


DejaDupConfigLocationTable* deja_dup_config_location_table_construct (GType object_type, GtkSizeGroup* sg) {
	DejaDupConfigLocationTable * self = NULL;
	g_return_val_if_fail (sg != NULL, NULL);
	self = (DejaDupConfigLocationTable*) g_object_new (object_type, "label-sizes", sg, NULL);
	return self;
}


DejaDupConfigLocationTable* deja_dup_config_location_table_new (GtkSizeGroup* sg) {
	return deja_dup_config_location_table_construct (DEJA_DUP_TYPE_CONFIG_LOCATION_TABLE, sg);
}


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


static Block1Data* block1_data_ref (Block1Data* _data1_) {
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void block1_data_unref (Block1Data* _data1_) {
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		_g_object_unref0 (_data1_->self);
		_g_object_unref0 (_data1_->label);
		_g_object_unref0 (_data1_->w);
		_g_object_unref0 (_data1_->check);
		g_slice_free (Block1Data, _data1_);
	}
}


static void _lambda1_ (Block1Data* _data1_) {
	DejaDupConfigLocationTable * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	self = _data1_->self;
	_tmp0_ = deja_dup_togglable_get_active (_data1_->check);
	gtk_widget_set_sensitive ((GtkWidget*) _data1_->label, _tmp0_);
	_tmp1_ = deja_dup_togglable_get_active (_data1_->check);
	gtk_widget_set_sensitive (_data1_->w, _tmp1_);
}


static void __lambda1__deja_dup_togglable_toggled (DejaDupTogglable* _sender, DejaDupTogglable* t, gboolean user, gpointer self) {
	_lambda1_ (self);
}


void deja_dup_config_location_table_add_widget (DejaDupConfigLocationTable* self, const gchar* msg, GtkWidget* w, DejaDupTogglable* check) {
	Block1Data* _data1_;
	gchar* indent = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	GtkLabel* _tmp6_ = NULL;
	GtkLabel* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (msg != NULL);
	g_return_if_fail (w != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_data1_->w = _g_object_ref0 (w);
	_data1_->check = _g_object_ref0 (check);
	if (_data1_->check == NULL) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		_tmp0_ = g_strdup ("    ");
		_tmp1_ = _tmp0_;
		_g_free0 (indent);
		indent = _tmp1_;
	} else {
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = g_strdup ("        ");
		_tmp3_ = _tmp2_;
		_g_free0 (indent);
		indent = _tmp3_;
	}
	_tmp4_ = g_strdup_printf ("%s%s", indent, msg);
	_tmp5_ = _tmp4_;
	_tmp6_ = (GtkLabel*) gtk_label_new (_tmp5_);
	_data1_->label = (_tmp7_ = g_object_ref_sink (_tmp6_), _g_free0 (_tmp5_), _tmp7_);
	g_object_set ((GObject*) _data1_->label, "mnemonic-widget", _data1_->w, "use-underline", TRUE, "xalign", 0.0f, NULL);
	gtk_size_group_add_widget (self->priv->_label_sizes, (GtkWidget*) _data1_->label);
	gtk_table_attach ((GtkTable*) self, (GtkWidget*) _data1_->label, (guint) 0, (guint) 1, (guint) self->row, (guint) (self->row + 1), GTK_FILL, GTK_FILL, (guint) 0, (guint) 0);
	gtk_table_attach ((GtkTable*) self, _data1_->w, (guint) 1, (guint) 2, (guint) self->row, (guint) (self->row + 1), GTK_FILL | GTK_EXPAND, GTK_FILL, (guint) 0, (guint) 0);
	self->row = self->row + 1;
	if (_data1_->check != NULL) {
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp8_ = deja_dup_togglable_get_active (_data1_->check);
		gtk_widget_set_sensitive ((GtkWidget*) _data1_->label, _tmp8_);
		_tmp9_ = deja_dup_togglable_get_active (_data1_->check);
		gtk_widget_set_sensitive (_data1_->w, _tmp9_);
		g_signal_connect_data (_data1_->check, "toggled", (GCallback) __lambda1__deja_dup_togglable_toggled, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	}
	_g_free0 (indent);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}


static Block2Data* block2_data_ref (Block2Data* _data2_) {
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}


static void block2_data_unref (Block2Data* _data2_) {
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		_g_object_unref0 (_data2_->self);
		_g_object_unref0 (_data2_->hbox);
		_g_object_unref0 (_data2_->check);
		g_slice_free (Block2Data, _data2_);
	}
}


static void _lambda2_ (Block2Data* _data2_) {
	DejaDupConfigLocationTable * self;
	gboolean _tmp0_;
	self = _data2_->self;
	_tmp0_ = deja_dup_togglable_get_active (_data2_->check);
	gtk_widget_set_sensitive ((GtkWidget*) _data2_->hbox, _tmp0_);
}


static void __lambda2__deja_dup_togglable_toggled (DejaDupTogglable* _sender, DejaDupTogglable* t, gboolean user, gpointer self) {
	_lambda2_ (self);
}


void deja_dup_config_location_table_add_wide_widget (DejaDupConfigLocationTable* self, GtkWidget* w, DejaDupTogglable* check) {
	Block2Data* _data2_;
	gchar* indent = NULL;
	GtkHBox* _tmp4_ = NULL;
	GtkLabel* _tmp5_ = NULL;
	GtkLabel* label;
	g_return_if_fail (self != NULL);
	g_return_if_fail (w != NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_data2_->check = _g_object_ref0 (check);
	if (_data2_->check == NULL) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		_tmp0_ = g_strdup ("    ");
		_tmp1_ = _tmp0_;
		_g_free0 (indent);
		indent = _tmp1_;
	} else {
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = g_strdup ("        ");
		_tmp3_ = _tmp2_;
		_g_free0 (indent);
		indent = _tmp3_;
	}
	_tmp4_ = (GtkHBox*) gtk_hbox_new (FALSE, 0);
	_data2_->hbox = g_object_ref_sink (_tmp4_);
	_tmp5_ = (GtkLabel*) gtk_label_new (indent);
	label = g_object_ref_sink (_tmp5_);
	gtk_box_pack_start ((GtkBox*) _data2_->hbox, (GtkWidget*) label, FALSE, FALSE, (guint) 0);
	gtk_box_pack_start ((GtkBox*) _data2_->hbox, w, TRUE, TRUE, (guint) 0);
	gtk_table_attach ((GtkTable*) self, (GtkWidget*) _data2_->hbox, (guint) 0, (guint) 2, (guint) self->row, (guint) (self->row + 1), GTK_FILL | GTK_EXPAND, GTK_FILL, (guint) 0, (guint) 0);
	self->row = self->row + 1;
	if (_data2_->check != NULL) {
		gboolean _tmp6_;
		_tmp6_ = deja_dup_togglable_get_active (_data2_->check);
		gtk_widget_set_sensitive ((GtkWidget*) _data2_->hbox, _tmp6_);
		g_signal_connect_data (_data2_->check, "toggled", (GCallback) __lambda2__deja_dup_togglable_toggled, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	}
	_g_object_unref0 (label);
	_g_free0 (indent);
	block2_data_unref (_data2_);
	_data2_ = NULL;
}


void deja_dup_config_location_table_add_optional_label (DejaDupConfigLocationTable* self) {
	const gchar* _tmp0_ = NULL;
	GtkLabel* _tmp1_ = NULL;
	GtkLabel* label;
	g_return_if_fail (self != NULL);
	_tmp0_ = _ ("Optional information:");
	_tmp1_ = (GtkLabel*) gtk_label_new (_tmp0_);
	label = g_object_ref_sink (_tmp1_);
	g_object_set ((GObject*) label, "xalign", 0.0f, NULL);
	deja_dup_config_location_table_add_wide_widget (self, (GtkWidget*) label, NULL);
	_g_object_unref0 (label);
}


GtkSizeGroup* deja_dup_config_location_table_get_label_sizes (DejaDupConfigLocationTable* self) {
	GtkSizeGroup* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_label_sizes;
	return result;
}


static void deja_dup_config_location_table_set_label_sizes (DejaDupConfigLocationTable* self, GtkSizeGroup* value) {
	GtkSizeGroup* _tmp0_;
	GtkSizeGroup* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_tmp1_ = _tmp0_;
	_g_object_unref0 (self->priv->_label_sizes);
	self->priv->_label_sizes = _tmp1_;
	g_object_notify ((GObject *) self, "label-sizes");
}


static GObject * deja_dup_config_location_table_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	DejaDupConfigLocationTable * self;
	parent_class = G_OBJECT_CLASS (deja_dup_config_location_table_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = DEJA_DUP_CONFIG_LOCATION_TABLE (obj);
	g_object_set ((GtkTable*) self, "row-spacing", (guint) 6, NULL);
	g_object_set ((GtkTable*) self, "column-spacing", (guint) 6, NULL);
	return obj;
}


static void deja_dup_config_location_table_class_init (DejaDupConfigLocationTableClass * klass) {
	deja_dup_config_location_table_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DejaDupConfigLocationTablePrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_deja_dup_config_location_table_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_deja_dup_config_location_table_set_property;
	G_OBJECT_CLASS (klass)->constructor = deja_dup_config_location_table_constructor;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_config_location_table_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEJA_DUP_CONFIG_LOCATION_TABLE_LABEL_SIZES, g_param_spec_object ("label-sizes", "label-sizes", "label-sizes", GTK_TYPE_SIZE_GROUP, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}


static void deja_dup_config_location_table_instance_init (DejaDupConfigLocationTable * self) {
	self->priv = DEJA_DUP_CONFIG_LOCATION_TABLE_GET_PRIVATE (self);
	self->row = 0;
}


static void deja_dup_config_location_table_finalize (GObject* obj) {
	DejaDupConfigLocationTable * self;
	self = DEJA_DUP_CONFIG_LOCATION_TABLE (obj);
	_g_object_unref0 (self->priv->_label_sizes);
	G_OBJECT_CLASS (deja_dup_config_location_table_parent_class)->finalize (obj);
}


GType deja_dup_config_location_table_get_type (void) {
	static volatile gsize deja_dup_config_location_table_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_config_location_table_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupConfigLocationTableClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_config_location_table_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupConfigLocationTable), 0, (GInstanceInitFunc) deja_dup_config_location_table_instance_init, NULL };
		GType deja_dup_config_location_table_type_id;
		deja_dup_config_location_table_type_id = g_type_register_static (GTK_TYPE_TABLE, "DejaDupConfigLocationTable", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_config_location_table_type_id__volatile, deja_dup_config_location_table_type_id);
	}
	return deja_dup_config_location_table_type_id__volatile;
}


static void _vala_deja_dup_config_location_table_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	DejaDupConfigLocationTable * self;
	self = DEJA_DUP_CONFIG_LOCATION_TABLE (object);
	switch (property_id) {
		case DEJA_DUP_CONFIG_LOCATION_TABLE_LABEL_SIZES:
		g_value_set_object (value, deja_dup_config_location_table_get_label_sizes (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_deja_dup_config_location_table_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	DejaDupConfigLocationTable * self;
	self = DEJA_DUP_CONFIG_LOCATION_TABLE (object);
	switch (property_id) {
		case DEJA_DUP_CONFIG_LOCATION_TABLE_LABEL_SIZES:
		deja_dup_config_location_table_set_label_sizes (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



