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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
    This file is part of Déjà Dup.
    For copyright information, see AUTHORS.

    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>


#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;

#define DEJA_DUP_TYPE_TOGGLE_GROUP (deja_dup_toggle_group_get_type ())
#define DEJA_DUP_TOGGLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_TOGGLE_GROUP, DejaDupToggleGroup))
#define DEJA_DUP_TOGGLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_TOGGLE_GROUP, DejaDupToggleGroupClass))
#define DEJA_DUP_IS_TOGGLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_TOGGLE_GROUP))
#define DEJA_DUP_IS_TOGGLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_TOGGLE_GROUP))
#define DEJA_DUP_TOGGLE_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_TOGGLE_GROUP, DejaDupToggleGroupClass))

typedef struct _DejaDupToggleGroup DejaDupToggleGroup;
typedef struct _DejaDupToggleGroupClass DejaDupToggleGroupClass;
typedef struct _DejaDupToggleGroupPrivate DejaDupToggleGroupPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))

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

struct _DejaDupToggleGroup {
	GObject parent_instance;
	DejaDupToggleGroupPrivate * priv;
};

struct _DejaDupToggleGroupClass {
	GObjectClass parent_class;
};

struct _DejaDupToggleGroupPrivate {
	DejaDupTogglable* _toggle;
	GtkToggleButton* _toggle_button;
	GList* dependents;
};


static gpointer deja_dup_toggle_group_parent_class = NULL;

GType deja_dup_togglable_get_type (void) G_GNUC_CONST;
gboolean deja_dup_togglable_get_active (DejaDupTogglable* self);
static void g_cclosure_user_marshal_VOID__OBJECT_BOOLEAN (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
GType deja_dup_toggle_group_get_type (void) G_GNUC_CONST;
#define DEJA_DUP_TOGGLE_GROUP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEJA_DUP_TYPE_TOGGLE_GROUP, DejaDupToggleGroupPrivate))
enum  {
	DEJA_DUP_TOGGLE_GROUP_DUMMY_PROPERTY,
	DEJA_DUP_TOGGLE_GROUP_TOGGLE,
	DEJA_DUP_TOGGLE_GROUP_TOGGLE_BUTTON
};
static void _g_object_unref0_ (gpointer var);
static void _g_list_free__g_object_unref0_ (GList* self);
DejaDupToggleGroup* deja_dup_toggle_group_new (DejaDupTogglable* toggle);
DejaDupToggleGroup* deja_dup_toggle_group_construct (GType object_type, DejaDupTogglable* toggle);
DejaDupToggleGroup* deja_dup_toggle_group_new_with_button (GtkToggleButton* toggle_button);
DejaDupToggleGroup* deja_dup_toggle_group_construct_with_button (GType object_type, GtkToggleButton* toggle_button);
void deja_dup_toggle_group_add_dependent (DejaDupToggleGroup* self, GtkWidget* w);
static gboolean deja_dup_toggle_group_get_active (DejaDupToggleGroup* self);
void deja_dup_toggle_group_check (DejaDupToggleGroup* self);
DejaDupTogglable* deja_dup_toggle_group_get_toggle (DejaDupToggleGroup* self);
GtkToggleButton* deja_dup_toggle_group_get_toggle_button (DejaDupToggleGroup* self);
static void deja_dup_toggle_group_set_toggle (DejaDupToggleGroup* self, DejaDupTogglable* value);
static void deja_dup_toggle_group_set_toggle_button (DejaDupToggleGroup* self, GtkToggleButton* value);
static GObject * deja_dup_toggle_group_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void _lambda4_ (DejaDupToggleGroup* self);
static void __lambda4__deja_dup_togglable_toggled (DejaDupTogglable* _sender, DejaDupTogglable* t, gboolean user, gpointer self);
static void _lambda5_ (DejaDupToggleGroup* self);
static void __lambda5__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self);
static void deja_dup_toggle_group_finalize (GObject* obj);
static void _vala_deja_dup_toggle_group_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_deja_dup_toggle_group_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


gboolean deja_dup_togglable_get_active (DejaDupTogglable* self) {
	return DEJA_DUP_TOGGLABLE_GET_INTERFACE (self)->get_active (self);
}


static void g_cclosure_user_marshal_VOID__OBJECT_BOOLEAN (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__OBJECT_BOOLEAN) (gpointer data1, gpointer arg_1, gboolean arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_BOOLEAN callback;
	register GCClosure * cc;
	register gpointer data1, data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_boolean (param_values + 2), data2);
}


static void deja_dup_togglable_base_init (DejaDupTogglableIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
		g_signal_new ("toggled", DEJA_DUP_TYPE_TOGGLABLE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2, DEJA_DUP_TYPE_TOGGLABLE, G_TYPE_BOOLEAN);
	}
}


GType deja_dup_togglable_get_type (void) {
	static volatile gsize deja_dup_togglable_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_togglable_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupTogglableIface), (GBaseInitFunc) deja_dup_togglable_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType deja_dup_togglable_type_id;
		deja_dup_togglable_type_id = g_type_register_static (G_TYPE_INTERFACE, "DejaDupTogglable", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (deja_dup_togglable_type_id, G_TYPE_OBJECT);
		g_once_init_leave (&deja_dup_togglable_type_id__volatile, deja_dup_togglable_type_id);
	}
	return deja_dup_togglable_type_id__volatile;
}


static void _g_object_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static void _g_list_free__g_object_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
	g_list_free (self);
}


DejaDupToggleGroup* deja_dup_toggle_group_construct (GType object_type, DejaDupTogglable* toggle) {
	DejaDupToggleGroup * self = NULL;
	g_return_val_if_fail (toggle != NULL, NULL);
	self = (DejaDupToggleGroup*) g_object_new (object_type, "toggle", toggle, NULL);
	return self;
}


DejaDupToggleGroup* deja_dup_toggle_group_new (DejaDupTogglable* toggle) {
	return deja_dup_toggle_group_construct (DEJA_DUP_TYPE_TOGGLE_GROUP, toggle);
}


DejaDupToggleGroup* deja_dup_toggle_group_construct_with_button (GType object_type, GtkToggleButton* toggle_button) {
	DejaDupToggleGroup * self = NULL;
	g_return_val_if_fail (toggle_button != NULL, NULL);
	self = (DejaDupToggleGroup*) g_object_new (object_type, "toggle-button", toggle_button, NULL);
	return self;
}


DejaDupToggleGroup* deja_dup_toggle_group_new_with_button (GtkToggleButton* toggle_button) {
	return deja_dup_toggle_group_construct_with_button (DEJA_DUP_TYPE_TOGGLE_GROUP, toggle_button);
}


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


void deja_dup_toggle_group_add_dependent (DejaDupToggleGroup* self, GtkWidget* w) {
	GtkWidget* _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (w != NULL);
	_tmp0_ = _g_object_ref0 (w);
	self->priv->dependents = g_list_append (self->priv->dependents, _tmp0_);
	_tmp1_ = deja_dup_toggle_group_get_active (self);
	gtk_widget_set_sensitive (w, _tmp1_);
}


void deja_dup_toggle_group_check (DejaDupToggleGroup* self) {
	gboolean _tmp0_;
	gboolean on;
	g_return_if_fail (self != NULL);
	_tmp0_ = deja_dup_toggle_group_get_active (self);
	on = _tmp0_;
	{
		GList* w_collection;
		GList* w_it;
		w_collection = self->priv->dependents;
		for (w_it = w_collection; w_it != NULL; w_it = w_it->next) {
			GtkWidget* _tmp1_;
			GtkWidget* w;
			_tmp1_ = _g_object_ref0 ((GtkWidget*) w_it->data);
			w = _tmp1_;
			{
				gtk_widget_set_sensitive (w, on);
				_g_object_unref0 (w);
			}
		}
	}
}


static gboolean deja_dup_toggle_group_get_active (DejaDupToggleGroup* self) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	if (self->priv->_toggle != NULL) {
		gboolean _tmp0_;
		_tmp0_ = deja_dup_togglable_get_active (self->priv->_toggle);
		result = _tmp0_;
		return result;
	} else {
		gboolean _tmp1_;
		_tmp1_ = gtk_toggle_button_get_active (self->priv->_toggle_button);
		result = _tmp1_;
		return result;
	}
}


DejaDupTogglable* deja_dup_toggle_group_get_toggle (DejaDupToggleGroup* self) {
	DejaDupTogglable* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_toggle;
	return result;
}


static void deja_dup_toggle_group_set_toggle (DejaDupToggleGroup* self, DejaDupTogglable* value) {
	DejaDupTogglable* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_toggle);
	self->priv->_toggle = _tmp0_;
	g_object_notify ((GObject *) self, "toggle");
}


GtkToggleButton* deja_dup_toggle_group_get_toggle_button (DejaDupToggleGroup* self) {
	GtkToggleButton* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_toggle_button;
	return result;
}


static void deja_dup_toggle_group_set_toggle_button (DejaDupToggleGroup* self, GtkToggleButton* value) {
	GtkToggleButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_toggle_button);
	self->priv->_toggle_button = _tmp0_;
	g_object_notify ((GObject *) self, "toggle-button");
}


static void _lambda4_ (DejaDupToggleGroup* self) {
	deja_dup_toggle_group_check (self);
}


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


static void _lambda5_ (DejaDupToggleGroup* self) {
	deja_dup_toggle_group_check (self);
}


static void __lambda5__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) {
	_lambda5_ (self);
}


static GObject * deja_dup_toggle_group_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	DejaDupToggleGroup * self;
	parent_class = G_OBJECT_CLASS (deja_dup_toggle_group_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = DEJA_DUP_TOGGLE_GROUP (obj);
	if (self->priv->_toggle != NULL) {
		g_signal_connect_object (self->priv->_toggle, "toggled", (GCallback) __lambda4__deja_dup_togglable_toggled, self, 0);
	} else {
		g_signal_connect_object (self->priv->_toggle_button, "toggled", (GCallback) __lambda5__gtk_toggle_button_toggled, self, 0);
	}
	return obj;
}


static void deja_dup_toggle_group_class_init (DejaDupToggleGroupClass * klass) {
	deja_dup_toggle_group_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DejaDupToggleGroupPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_deja_dup_toggle_group_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_deja_dup_toggle_group_set_property;
	G_OBJECT_CLASS (klass)->constructor = deja_dup_toggle_group_constructor;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_toggle_group_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEJA_DUP_TOGGLE_GROUP_TOGGLE, g_param_spec_object ("toggle", "toggle", "toggle", DEJA_DUP_TYPE_TOGGLABLE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEJA_DUP_TOGGLE_GROUP_TOGGLE_BUTTON, g_param_spec_object ("toggle-button", "toggle-button", "toggle-button", GTK_TYPE_TOGGLE_BUTTON, 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_toggle_group_instance_init (DejaDupToggleGroup * self) {
	self->priv = DEJA_DUP_TOGGLE_GROUP_GET_PRIVATE (self);
}


static void deja_dup_toggle_group_finalize (GObject* obj) {
	DejaDupToggleGroup * self;
	self = DEJA_DUP_TOGGLE_GROUP (obj);
	_g_object_unref0 (self->priv->_toggle);
	_g_object_unref0 (self->priv->_toggle_button);
	__g_list_free__g_object_unref0_0 (self->priv->dependents);
	G_OBJECT_CLASS (deja_dup_toggle_group_parent_class)->finalize (obj);
}


GType deja_dup_toggle_group_get_type (void) {
	static volatile gsize deja_dup_toggle_group_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_toggle_group_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupToggleGroupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_toggle_group_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupToggleGroup), 0, (GInstanceInitFunc) deja_dup_toggle_group_instance_init, NULL };
		GType deja_dup_toggle_group_type_id;
		deja_dup_toggle_group_type_id = g_type_register_static (G_TYPE_OBJECT, "DejaDupToggleGroup", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_toggle_group_type_id__volatile, deja_dup_toggle_group_type_id);
	}
	return deja_dup_toggle_group_type_id__volatile;
}


static void _vala_deja_dup_toggle_group_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	DejaDupToggleGroup * self;
	self = DEJA_DUP_TOGGLE_GROUP (object);
	switch (property_id) {
		case DEJA_DUP_TOGGLE_GROUP_TOGGLE:
		g_value_set_object (value, deja_dup_toggle_group_get_toggle (self));
		break;
		case DEJA_DUP_TOGGLE_GROUP_TOGGLE_BUTTON:
		g_value_set_object (value, deja_dup_toggle_group_get_toggle_button (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_deja_dup_toggle_group_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	DejaDupToggleGroup * self;
	self = DEJA_DUP_TOGGLE_GROUP (object);
	switch (property_id) {
		case DEJA_DUP_TOGGLE_GROUP_TOGGLE:
		deja_dup_toggle_group_set_toggle (self, g_value_get_object (value));
		break;
		case DEJA_DUP_TOGGLE_GROUP_TOGGLE_BUTTON:
		deja_dup_toggle_group_set_toggle_button (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



