/* contacts-settings.c generated by valac 0.36.4, the Vala compiler
 * generated from contacts-settings.vala, do not modify */

/*
 * Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
 *
 * This program 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.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <gobject/gvaluecollector.h>


#define CONTACTS_TYPE_SETTINGS (contacts_settings_get_type ())
#define CONTACTS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_SETTINGS, ContactsSettings))
#define CONTACTS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_SETTINGS, ContactsSettingsClass))
#define CONTACTS_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_SETTINGS))
#define CONTACTS_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_SETTINGS))
#define CONTACTS_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_SETTINGS, ContactsSettingsClass))

typedef struct _ContactsSettings ContactsSettings;
typedef struct _ContactsSettingsClass ContactsSettingsClass;
typedef struct _ContactsSettingsPrivate ContactsSettingsPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define CONTACTS_TYPE_APP (contacts_app_get_type ())
#define CONTACTS_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_TYPE_APP, ContactsApp))
#define CONTACTS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_TYPE_APP, ContactsAppClass))
#define CONTACTS_IS_APP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_TYPE_APP))
#define CONTACTS_IS_APP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_TYPE_APP))
#define CONTACTS_APP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_TYPE_APP, ContactsAppClass))

typedef struct _ContactsApp ContactsApp;
typedef struct _ContactsAppClass ContactsAppClass;
typedef struct _ContactsParamSpecSettings ContactsParamSpecSettings;

struct _ContactsSettings {
	GTypeInstance parent_instance;
	volatile int ref_count;
	ContactsSettingsPrivate * priv;
};

struct _ContactsSettingsClass {
	GTypeClass parent_class;
	void (*finalize) (ContactsSettings *self);
};

struct _ContactsSettingsPrivate {
	GSettings* settings;
};

struct _ContactsParamSpecSettings {
	GParamSpec parent_instance;
};


static gpointer contacts_settings_parent_class = NULL;

gpointer contacts_settings_ref (gpointer instance);
void contacts_settings_unref (gpointer instance);
GParamSpec* contacts_param_spec_settings (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void contacts_value_set_settings (GValue* value, gpointer v_object);
void contacts_value_take_settings (GValue* value, gpointer v_object);
gpointer contacts_value_get_settings (const GValue* value);
GType contacts_settings_get_type (void) G_GNUC_CONST;
#define CONTACTS_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CONTACTS_TYPE_SETTINGS, ContactsSettingsPrivate))
enum  {
	CONTACTS_SETTINGS_DUMMY_PROPERTY
};
GType contacts_app_get_type (void) G_GNUC_CONST;
ContactsSettings* contacts_settings_new (ContactsApp* app);
ContactsSettings* contacts_settings_construct (GType object_type, ContactsApp* app);
gboolean contacts_settings_get_did_initial_setup (ContactsSettings* self);
void contacts_settings_set_did_initial_setup (ContactsSettings* self, gboolean value);
static void contacts_settings_finalize (ContactsSettings * obj);


ContactsSettings* contacts_settings_construct (GType object_type, ContactsApp* app) {
	ContactsSettings* self = NULL;
	ContactsApp* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GSettings* _tmp3_;
	g_return_val_if_fail (app != NULL, NULL);
	self = (ContactsSettings*) g_type_create_instance (object_type);
	_tmp0_ = app;
	_tmp1_ = g_application_get_application_id ((GApplication*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_settings_new (_tmp2_);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp3_;
	return self;
}


ContactsSettings* contacts_settings_new (ContactsApp* app) {
	return contacts_settings_construct (CONTACTS_TYPE_SETTINGS, app);
}


gboolean contacts_settings_get_did_initial_setup (ContactsSettings* self) {
	gboolean result;
	GSettings* _tmp0_;
	gboolean _tmp1_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->settings;
	_tmp1_ = g_settings_get_boolean (_tmp0_, "did-initial-setup");
	result = _tmp1_;
	return result;
}


void contacts_settings_set_did_initial_setup (ContactsSettings* self, gboolean value) {
	GSettings* _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->settings;
	_tmp1_ = value;
	g_settings_set_boolean (_tmp0_, "did-initial-setup", _tmp1_);
}


static void contacts_value_settings_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


static void contacts_value_settings_free_value (GValue* value) {
	if (value->data[0].v_pointer) {
		contacts_settings_unref (value->data[0].v_pointer);
	}
}


static void contacts_value_settings_copy_value (const GValue* src_value, GValue* dest_value) {
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = contacts_settings_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


static gpointer contacts_value_settings_peek_pointer (const GValue* value) {
	return value->data[0].v_pointer;
}


static gchar* contacts_value_settings_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		ContactsSettings * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = contacts_settings_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* contacts_value_settings_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	ContactsSettings ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = contacts_settings_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* contacts_param_spec_settings (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ContactsParamSpecSettings* spec;
	g_return_val_if_fail (g_type_is_a (object_type, CONTACTS_TYPE_SETTINGS), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}


gpointer contacts_value_get_settings (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CONTACTS_TYPE_SETTINGS), NULL);
	return value->data[0].v_pointer;
}


void contacts_value_set_settings (GValue* value, gpointer v_object) {
	ContactsSettings * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CONTACTS_TYPE_SETTINGS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, CONTACTS_TYPE_SETTINGS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		contacts_settings_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		contacts_settings_unref (old);
	}
}


void contacts_value_take_settings (GValue* value, gpointer v_object) {
	ContactsSettings * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CONTACTS_TYPE_SETTINGS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, CONTACTS_TYPE_SETTINGS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		contacts_settings_unref (old);
	}
}


static void contacts_settings_class_init (ContactsSettingsClass * klass) {
	contacts_settings_parent_class = g_type_class_peek_parent (klass);
	((ContactsSettingsClass *) klass)->finalize = contacts_settings_finalize;
	g_type_class_add_private (klass, sizeof (ContactsSettingsPrivate));
}


static void contacts_settings_instance_init (ContactsSettings * self) {
	self->priv = CONTACTS_SETTINGS_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void contacts_settings_finalize (ContactsSettings * obj) {
	ContactsSettings * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_SETTINGS, ContactsSettings);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->settings);
}


/**
 * Provides a convenient interface to deal with the settings.
 */
GType contacts_settings_get_type (void) {
	static volatile gsize contacts_settings_type_id__volatile = 0;
	if (g_once_init_enter (&contacts_settings_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { contacts_value_settings_init, contacts_value_settings_free_value, contacts_value_settings_copy_value, contacts_value_settings_peek_pointer, "p", contacts_value_settings_collect_value, "p", contacts_value_settings_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (ContactsSettingsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_settings_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsSettings), 0, (GInstanceInitFunc) contacts_settings_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType contacts_settings_type_id;
		contacts_settings_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ContactsSettings", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&contacts_settings_type_id__volatile, contacts_settings_type_id);
	}
	return contacts_settings_type_id__volatile;
}


gpointer contacts_settings_ref (gpointer instance) {
	ContactsSettings * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


void contacts_settings_unref (gpointer instance) {
	ContactsSettings * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		CONTACTS_SETTINGS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



