/* SimpleSettings.c generated by valac 0.12.1, the Vala compiler
 * generated from SimpleSettings.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 <gio/gio.h>
#include <stdlib.h>
#include <string.h>


#define DEJA_DUP_TYPE_SIMPLE_SETTINGS (deja_dup_simple_settings_get_type ())
#define DEJA_DUP_SIMPLE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_SIMPLE_SETTINGS, DejaDupSimpleSettings))
#define DEJA_DUP_SIMPLE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_SIMPLE_SETTINGS, DejaDupSimpleSettingsClass))
#define DEJA_DUP_IS_SIMPLE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_SIMPLE_SETTINGS))
#define DEJA_DUP_IS_SIMPLE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_SIMPLE_SETTINGS))
#define DEJA_DUP_SIMPLE_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_SIMPLE_SETTINGS, DejaDupSimpleSettingsClass))

typedef struct _DejaDupSimpleSettings DejaDupSimpleSettings;
typedef struct _DejaDupSimpleSettingsClass DejaDupSimpleSettingsClass;
typedef struct _DejaDupSimpleSettingsPrivate DejaDupSimpleSettingsPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))

struct _DejaDupSimpleSettings {
	GSettings parent_instance;
	DejaDupSimpleSettingsPrivate * priv;
};

struct _DejaDupSimpleSettingsClass {
	GSettingsClass parent_class;
};

struct _DejaDupSimpleSettingsPrivate {
	gboolean _read_only;
};


static gpointer deja_dup_simple_settings_parent_class = NULL;

GType deja_dup_simple_settings_get_type (void) G_GNUC_CONST;
#define DEJA_DUP_SIMPLE_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEJA_DUP_TYPE_SIMPLE_SETTINGS, DejaDupSimpleSettingsPrivate))
enum  {
	DEJA_DUP_SIMPLE_SETTINGS_DUMMY_PROPERTY,
	DEJA_DUP_SIMPLE_SETTINGS_READ_ONLY
};
DejaDupSimpleSettings* deja_dup_simple_settings_new (const gchar* schema, gboolean ro);
DejaDupSimpleSettings* deja_dup_simple_settings_construct (GType object_type, const gchar* schema, gboolean ro);
void deja_dup_simple_settings_apply (DejaDupSimpleSettings* self);
gboolean deja_dup_simple_settings_get_read_only (DejaDupSimpleSettings* self);
void deja_dup_simple_settings_set_string (DejaDupSimpleSettings* self, const gchar* k, const gchar* v);
void deja_dup_simple_settings_set_boolean (DejaDupSimpleSettings* self, const gchar* k, gboolean v);
void deja_dup_simple_settings_set_int (DejaDupSimpleSettings* self, const gchar* k, gint v);
void deja_dup_simple_settings_set_value (DejaDupSimpleSettings* self, const gchar* k, GVariant* v);
void deja_dup_simple_settings_set_read_only (DejaDupSimpleSettings* self, gboolean value);
static void deja_dup_simple_settings_finalize (GObject* obj);
static void _vala_deja_dup_simple_settings_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_deja_dup_simple_settings_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


DejaDupSimpleSettings* deja_dup_simple_settings_construct (GType object_type, const gchar* schema, gboolean ro) {
	DejaDupSimpleSettings * self = NULL;
	g_return_val_if_fail (schema != NULL, NULL);
	self = (DejaDupSimpleSettings*) g_object_new (object_type, "schema", schema, "read-only", ro, NULL);
	return self;
}


DejaDupSimpleSettings* deja_dup_simple_settings_new (const gchar* schema, gboolean ro) {
	return deja_dup_simple_settings_construct (DEJA_DUP_TYPE_SIMPLE_SETTINGS, schema, ro);
}


void deja_dup_simple_settings_apply (DejaDupSimpleSettings* self) {
	g_return_if_fail (self != NULL);
	if (!self->priv->_read_only) {
		g_settings_apply (G_SETTINGS (self));
	}
}


void deja_dup_simple_settings_set_string (DejaDupSimpleSettings* self, const gchar* k, const gchar* v) {
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (k != NULL);
	g_return_if_fail (v != NULL);
	_tmp0_ = g_settings_get_string ((GSettings*) self, k);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strcmp0 (_tmp1_, v) != 0;
	_g_free0 (_tmp1_);
	if (_tmp2_) {
		g_settings_set_string (G_SETTINGS (self), k, v);
	}
}


void deja_dup_simple_settings_set_boolean (DejaDupSimpleSettings* self, const gchar* k, gboolean v) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (k != NULL);
	_tmp0_ = g_settings_get_boolean ((GSettings*) self, k);
	if (_tmp0_ != v) {
		g_settings_set_boolean (G_SETTINGS (self), k, v);
	}
}


void deja_dup_simple_settings_set_int (DejaDupSimpleSettings* self, const gchar* k, gint v) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (k != NULL);
	_tmp0_ = g_settings_get_int ((GSettings*) self, k);
	if (_tmp0_ != v) {
		g_settings_set_int (G_SETTINGS (self), k, v);
	}
}


void deja_dup_simple_settings_set_value (DejaDupSimpleSettings* self, const gchar* k, GVariant* v) {
	GVariant* _tmp0_ = NULL;
	GVariant* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (k != NULL);
	g_return_if_fail (v != NULL);
	_tmp0_ = g_settings_get_value ((GSettings*) self, k);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_variant_equal (_tmp1_, v);
	_tmp3_ = !_tmp2_;
	_g_variant_unref0 (_tmp1_);
	if (_tmp3_) {
		g_settings_set_value (G_SETTINGS (self), k, v);
	}
}


gboolean deja_dup_simple_settings_get_read_only (DejaDupSimpleSettings* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_read_only;
	return result;
}


void deja_dup_simple_settings_set_read_only (DejaDupSimpleSettings* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_read_only = value;
	g_object_notify ((GObject *) self, "read-only");
}


static void deja_dup_simple_settings_class_init (DejaDupSimpleSettingsClass * klass) {
	deja_dup_simple_settings_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DejaDupSimpleSettingsPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_deja_dup_simple_settings_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_deja_dup_simple_settings_set_property;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_simple_settings_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEJA_DUP_SIMPLE_SETTINGS_READ_ONLY, g_param_spec_boolean ("read-only", "read-only", "read-only", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void deja_dup_simple_settings_instance_init (DejaDupSimpleSettings * self) {
	self->priv = DEJA_DUP_SIMPLE_SETTINGS_GET_PRIVATE (self);
}


static void deja_dup_simple_settings_finalize (GObject* obj) {
	DejaDupSimpleSettings * self;
	self = DEJA_DUP_SIMPLE_SETTINGS (obj);
	G_OBJECT_CLASS (deja_dup_simple_settings_parent_class)->finalize (obj);
}


GType deja_dup_simple_settings_get_type (void) {
	static volatile gsize deja_dup_simple_settings_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_simple_settings_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupSimpleSettingsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_simple_settings_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupSimpleSettings), 0, (GInstanceInitFunc) deja_dup_simple_settings_instance_init, NULL };
		GType deja_dup_simple_settings_type_id;
		deja_dup_simple_settings_type_id = g_type_register_static (G_TYPE_SETTINGS, "DejaDupSimpleSettings", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_simple_settings_type_id__volatile, deja_dup_simple_settings_type_id);
	}
	return deja_dup_simple_settings_type_id__volatile;
}


static void _vala_deja_dup_simple_settings_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	DejaDupSimpleSettings * self;
	self = DEJA_DUP_SIMPLE_SETTINGS (object);
	switch (property_id) {
		case DEJA_DUP_SIMPLE_SETTINGS_READ_ONLY:
		g_value_set_boolean (value, deja_dup_simple_settings_get_read_only (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_deja_dup_simple_settings_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	DejaDupSimpleSettings * self;
	self = DEJA_DUP_SIMPLE_SETTINGS (object);
	switch (property_id) {
		case DEJA_DUP_SIMPLE_SETTINGS_READ_ONLY:
		deja_dup_simple_settings_set_read_only (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



