/* ConfigEntry.c generated by valac 0.30.2, the Vala compiler
 * generated from ConfigEntry.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>
#include <gio/gio.h>
#include "deja.h"
#include <stdlib.h>
#include <string.h>
#include <atk/atk.h>
#include <gdk/gdk.h>


#define DEJA_DUP_TYPE_CONFIG_WIDGET (deja_dup_config_widget_get_type ())
#define DEJA_DUP_CONFIG_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_CONFIG_WIDGET, DejaDupConfigWidget))
#define DEJA_DUP_CONFIG_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_CONFIG_WIDGET, DejaDupConfigWidgetClass))
#define DEJA_DUP_IS_CONFIG_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_CONFIG_WIDGET))
#define DEJA_DUP_IS_CONFIG_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_CONFIG_WIDGET))
#define DEJA_DUP_CONFIG_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_CONFIG_WIDGET, DejaDupConfigWidgetClass))

typedef struct _DejaDupConfigWidget DejaDupConfigWidget;
typedef struct _DejaDupConfigWidgetClass DejaDupConfigWidgetClass;
typedef struct _DejaDupConfigWidgetPrivate DejaDupConfigWidgetPrivate;

#define DEJA_DUP_TYPE_CONFIG_ENTRY (deja_dup_config_entry_get_type ())
#define DEJA_DUP_CONFIG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_CONFIG_ENTRY, DejaDupConfigEntry))
#define DEJA_DUP_CONFIG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_CONFIG_ENTRY, DejaDupConfigEntryClass))
#define DEJA_DUP_IS_CONFIG_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_CONFIG_ENTRY))
#define DEJA_DUP_IS_CONFIG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_CONFIG_ENTRY))
#define DEJA_DUP_CONFIG_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_CONFIG_ENTRY, DejaDupConfigEntryClass))

typedef struct _DejaDupConfigEntry DejaDupConfigEntry;
typedef struct _DejaDupConfigEntryClass DejaDupConfigEntryClass;
typedef struct _DejaDupConfigEntryPrivate DejaDupConfigEntryPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _DejaDupConfigEntrySetFromConfigData DejaDupConfigEntrySetFromConfigData;

struct _DejaDupConfigWidget {
	GtkEventBox parent_instance;
	DejaDupConfigWidgetPrivate * priv;
	gboolean syncing;
	DejaDupFilteredSettings* settings;
	GList* all_settings;
};

struct _DejaDupConfigWidgetClass {
	GtkEventBoxClass parent_class;
	void (*set_from_config) (DejaDupConfigWidget* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*set_from_config_finish) (DejaDupConfigWidget* self, GAsyncResult* _res_);
};

struct _DejaDupConfigEntry {
	DejaDupConfigWidget parent_instance;
	DejaDupConfigEntryPrivate * priv;
	GtkEntry* entry;
};

struct _DejaDupConfigEntryClass {
	DejaDupConfigWidgetClass parent_class;
	void (*write_to_config) (DejaDupConfigEntry* self);
};

struct _DejaDupConfigEntryPrivate {
	gboolean _is_uri;
};

struct _DejaDupConfigEntrySetFromConfigData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	DejaDupConfigEntry* self;
	gchar* _tmp0_;
	gboolean _tmp1_;
	DejaDupFilteredSettings* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	DejaDupFilteredSettings* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* val;
	gchar* _tmp10_;
	GtkEntry* _tmp11_;
};


static gpointer deja_dup_config_entry_parent_class = NULL;

GType deja_dup_config_widget_get_type (void) G_GNUC_CONST;
GType deja_dup_config_entry_get_type (void) G_GNUC_CONST;
#define DEJA_DUP_CONFIG_ENTRY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEJA_DUP_TYPE_CONFIG_ENTRY, DejaDupConfigEntryPrivate))
enum  {
	DEJA_DUP_CONFIG_ENTRY_DUMMY_PROPERTY,
	DEJA_DUP_CONFIG_ENTRY_IS_URI
};
DejaDupConfigEntry* deja_dup_config_entry_new (const gchar* key, const gchar* ns, gboolean is_uri);
DejaDupConfigEntry* deja_dup_config_entry_construct (GType object_type, const gchar* key, const gchar* ns, gboolean is_uri);
gchar* deja_dup_config_entry_get_text (DejaDupConfigEntry* self);
void deja_dup_config_entry_set_accessible_name (DejaDupConfigEntry* self, const gchar* name);
static void deja_dup_config_entry_real_set_from_config_data_free (gpointer _data);
static void deja_dup_config_entry_real_set_from_config (DejaDupConfigWidget* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean deja_dup_config_entry_real_set_from_config_co (DejaDupConfigEntrySetFromConfigData* _data_);
gboolean deja_dup_config_entry_get_is_uri (DejaDupConfigEntry* self);
const gchar* deja_dup_config_widget_get_key (DejaDupConfigWidget* self);
void deja_dup_config_entry_write_to_config (DejaDupConfigEntry* self);
static void deja_dup_config_entry_real_write_to_config (DejaDupConfigEntry* self);
static gboolean deja_dup_config_entry_handle_focus_out (DejaDupConfigEntry* self);
void deja_dup_config_entry_set_is_uri (DejaDupConfigEntry* self, gboolean value);
static GObject * deja_dup_config_entry_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
void deja_dup_config_widget_set_mnemonic_widget (DejaDupConfigWidget* self, GtkWidget* value);
void deja_dup_config_widget_set_from_config (DejaDupConfigWidget* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
void deja_dup_config_widget_set_from_config_finish (DejaDupConfigWidget* self, GAsyncResult* _res_);
static gboolean _deja_dup_config_entry_handle_focus_out_gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self);
static void deja_dup_config_entry_finalize (GObject* obj);
static void _vala_deja_dup_config_entry_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_deja_dup_config_entry_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


DejaDupConfigEntry* deja_dup_config_entry_construct (GType object_type, const gchar* key, const gchar* ns, gboolean is_uri) {
	DejaDupConfigEntry * self = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	g_return_val_if_fail (key != NULL, NULL);
	g_return_val_if_fail (ns != NULL, NULL);
	_tmp0_ = key;
	_tmp1_ = ns;
	_tmp2_ = is_uri;
	self = (DejaDupConfigEntry*) g_object_new (object_type, "key", _tmp0_, "ns", _tmp1_, "is-uri", _tmp2_, NULL);
	return self;
}


DejaDupConfigEntry* deja_dup_config_entry_new (const gchar* key, const gchar* ns, gboolean is_uri) {
	return deja_dup_config_entry_construct (DEJA_DUP_TYPE_CONFIG_ENTRY, key, ns, is_uri);
}


gchar* deja_dup_config_entry_get_text (DejaDupConfigEntry* self) {
	gchar* result = NULL;
	GtkEntry* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->entry;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	result = _tmp2_;
	return result;
}


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


void deja_dup_config_entry_set_accessible_name (DejaDupConfigEntry* self, const gchar* name) {
	AtkObject* accessible = NULL;
	GtkEntry* _tmp0_ = NULL;
	AtkObject* _tmp1_ = NULL;
	AtkObject* _tmp2_ = NULL;
	AtkObject* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = self->entry;
	_tmp1_ = gtk_widget_get_accessible ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	accessible = _tmp2_;
	_tmp3_ = accessible;
	if (_tmp3_ != NULL) {
		AtkObject* _tmp4_ = NULL;
		const gchar* _tmp5_ = NULL;
		_tmp4_ = accessible;
		_tmp5_ = name;
		atk_object_set_name (_tmp4_, _tmp5_);
	}
	_g_object_unref0 (accessible);
}


static void deja_dup_config_entry_real_set_from_config_data_free (gpointer _data) {
	DejaDupConfigEntrySetFromConfigData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DejaDupConfigEntrySetFromConfigData, _data_);
}


static void deja_dup_config_entry_real_set_from_config (DejaDupConfigWidget* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	DejaDupConfigEntry * self;
	DejaDupConfigEntrySetFromConfigData* _data_;
	DejaDupConfigEntry* _tmp0_ = NULL;
	self = (DejaDupConfigEntry*) base;
	_data_ = g_slice_new0 (DejaDupConfigEntrySetFromConfigData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, deja_dup_config_entry_real_set_from_config);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, deja_dup_config_entry_real_set_from_config_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	deja_dup_config_entry_real_set_from_config_co (_data_);
}


static void deja_dup_config_entry_real_set_from_config_finish (DejaDupConfigWidget* base, GAsyncResult* _res_) {
	DejaDupConfigEntrySetFromConfigData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean deja_dup_config_entry_real_set_from_config_co (DejaDupConfigEntrySetFromConfigData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = FALSE;
	_data_->_tmp1_ = _data_->self->priv->_is_uri;
	if (_data_->_tmp1_) {
		_data_->_tmp2_ = NULL;
		_data_->_tmp2_ = ((DejaDupConfigWidget*) _data_->self)->settings;
		_data_->_tmp3_ = NULL;
		_data_->_tmp3_ = deja_dup_config_widget_get_key ((DejaDupConfigWidget*) _data_->self);
		_data_->_tmp4_ = NULL;
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = NULL;
		_data_->_tmp5_ = deja_dup_filtered_settings_get_uri (_data_->_tmp2_, _data_->_tmp4_);
		_g_free0 (_data_->_tmp0_);
		_data_->_tmp0_ = _data_->_tmp5_;
	} else {
		_data_->_tmp6_ = NULL;
		_data_->_tmp6_ = ((DejaDupConfigWidget*) _data_->self)->settings;
		_data_->_tmp7_ = NULL;
		_data_->_tmp7_ = deja_dup_config_widget_get_key ((DejaDupConfigWidget*) _data_->self);
		_data_->_tmp8_ = NULL;
		_data_->_tmp8_ = _data_->_tmp7_;
		_data_->_tmp9_ = NULL;
		_data_->_tmp9_ = g_settings_get_string ((GSettings*) _data_->_tmp6_, _data_->_tmp8_);
		_g_free0 (_data_->_tmp0_);
		_data_->_tmp0_ = _data_->_tmp9_;
	}
	_data_->_tmp10_ = NULL;
	_data_->_tmp10_ = g_strdup (_data_->_tmp0_);
	_data_->val = _data_->_tmp10_;
	_data_->_tmp11_ = NULL;
	_data_->_tmp11_ = _data_->self->entry;
	gtk_entry_set_text (_data_->_tmp11_, _data_->val);
	_g_free0 (_data_->val);
	_g_free0 (_data_->_tmp0_);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void deja_dup_config_entry_real_write_to_config (DejaDupConfigEntry* self) {
	DejaDupFilteredSettings* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	GtkEntry* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	_tmp0_ = ((DejaDupConfigWidget*) self)->settings;
	_tmp1_ = deja_dup_config_widget_get_key ((DejaDupConfigWidget*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->entry;
	_tmp4_ = gtk_entry_get_text (_tmp3_);
	deja_dup_filtered_settings_set_string (_tmp0_, _tmp2_, _tmp4_);
}


void deja_dup_config_entry_write_to_config (DejaDupConfigEntry* self) {
	g_return_if_fail (self != NULL);
	DEJA_DUP_CONFIG_ENTRY_GET_CLASS (self)->write_to_config (self);
}


static gboolean deja_dup_config_entry_handle_focus_out (DejaDupConfigEntry* self) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	deja_dup_config_entry_write_to_config (self);
	result = FALSE;
	return result;
}


gboolean deja_dup_config_entry_get_is_uri (DejaDupConfigEntry* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_is_uri;
	result = _tmp0_;
	return result;
}


void deja_dup_config_entry_set_is_uri (DejaDupConfigEntry* self, gboolean value) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_is_uri = _tmp0_;
	g_object_notify ((GObject *) self, "is-uri");
}


static gboolean _deja_dup_config_entry_handle_focus_out_gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self) {
	gboolean result;
	result = deja_dup_config_entry_handle_focus_out ((DejaDupConfigEntry*) self);
	return result;
}


static GObject * deja_dup_config_entry_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	DejaDupConfigEntry * self;
	GtkEntry* _tmp0_ = NULL;
	GtkEntry* _tmp1_ = NULL;
	GtkEntry* _tmp2_ = NULL;
	GtkEntry* _tmp3_ = NULL;
	parent_class = G_OBJECT_CLASS (deja_dup_config_entry_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_CONFIG_ENTRY, DejaDupConfigEntry);
	_tmp0_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->entry);
	self->entry = _tmp0_;
	_tmp1_ = self->entry;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp1_);
	_tmp2_ = self->entry;
	deja_dup_config_widget_set_mnemonic_widget ((DejaDupConfigWidget*) self, (GtkWidget*) _tmp2_);
	deja_dup_config_widget_set_from_config ((DejaDupConfigWidget*) self, NULL, NULL);
	_tmp3_ = self->entry;
	g_signal_connect_object ((GtkWidget*) _tmp3_, "focus-out-event", (GCallback) _deja_dup_config_entry_handle_focus_out_gtk_widget_focus_out_event, self, 0);
	return obj;
}


static void deja_dup_config_entry_class_init (DejaDupConfigEntryClass * klass) {
	deja_dup_config_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DejaDupConfigEntryPrivate));
	((DejaDupConfigWidgetClass *) klass)->set_from_config = deja_dup_config_entry_real_set_from_config;
	((DejaDupConfigWidgetClass *) klass)->set_from_config_finish = deja_dup_config_entry_real_set_from_config_finish;
	((DejaDupConfigEntryClass *) klass)->write_to_config = deja_dup_config_entry_real_write_to_config;
	G_OBJECT_CLASS (klass)->get_property = _vala_deja_dup_config_entry_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_deja_dup_config_entry_set_property;
	G_OBJECT_CLASS (klass)->constructor = deja_dup_config_entry_constructor;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_config_entry_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEJA_DUP_CONFIG_ENTRY_IS_URI, g_param_spec_boolean ("is-uri", "is-uri", "is-uri", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void deja_dup_config_entry_instance_init (DejaDupConfigEntry * self) {
	self->priv = DEJA_DUP_CONFIG_ENTRY_GET_PRIVATE (self);
}


static void deja_dup_config_entry_finalize (GObject* obj) {
	DejaDupConfigEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_CONFIG_ENTRY, DejaDupConfigEntry);
	_g_object_unref0 (self->entry);
	G_OBJECT_CLASS (deja_dup_config_entry_parent_class)->finalize (obj);
}


GType deja_dup_config_entry_get_type (void) {
	static volatile gsize deja_dup_config_entry_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_config_entry_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupConfigEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_config_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupConfigEntry), 0, (GInstanceInitFunc) deja_dup_config_entry_instance_init, NULL };
		GType deja_dup_config_entry_type_id;
		deja_dup_config_entry_type_id = g_type_register_static (DEJA_DUP_TYPE_CONFIG_WIDGET, "DejaDupConfigEntry", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_config_entry_type_id__volatile, deja_dup_config_entry_type_id);
	}
	return deja_dup_config_entry_type_id__volatile;
}


static void _vala_deja_dup_config_entry_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	DejaDupConfigEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEJA_DUP_TYPE_CONFIG_ENTRY, DejaDupConfigEntry);
	switch (property_id) {
		case DEJA_DUP_CONFIG_ENTRY_IS_URI:
		g_value_set_boolean (value, deja_dup_config_entry_get_is_uri (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_deja_dup_config_entry_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	DejaDupConfigEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEJA_DUP_TYPE_CONFIG_ENTRY, DejaDupConfigEntry);
	switch (property_id) {
		case DEJA_DUP_CONFIG_ENTRY_IS_URI:
		deja_dup_config_entry_set_is_uri (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



