/* ConfigLabelLocation.c generated by valac 0.30.2, the Vala compiler
 * generated from ConfigLabelLocation.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 <pango/pango.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_LABEL (deja_dup_config_label_get_type ())
#define DEJA_DUP_CONFIG_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_CONFIG_LABEL, DejaDupConfigLabel))
#define DEJA_DUP_CONFIG_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_CONFIG_LABEL, DejaDupConfigLabelClass))
#define DEJA_DUP_IS_CONFIG_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_CONFIG_LABEL))
#define DEJA_DUP_IS_CONFIG_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_CONFIG_LABEL))
#define DEJA_DUP_CONFIG_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_CONFIG_LABEL, DejaDupConfigLabelClass))

typedef struct _DejaDupConfigLabel DejaDupConfigLabel;
typedef struct _DejaDupConfigLabelClass DejaDupConfigLabelClass;
typedef struct _DejaDupConfigLabelPrivate DejaDupConfigLabelPrivate;

#define DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION (deja_dup_config_label_location_get_type ())
#define DEJA_DUP_CONFIG_LABEL_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION, DejaDupConfigLabelLocation))
#define DEJA_DUP_CONFIG_LABEL_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION, DejaDupConfigLabelLocationClass))
#define DEJA_DUP_IS_CONFIG_LABEL_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION))
#define DEJA_DUP_IS_CONFIG_LABEL_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION))
#define DEJA_DUP_CONFIG_LABEL_LOCATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION, DejaDupConfigLabelLocationClass))

typedef struct _DejaDupConfigLabelLocation DejaDupConfigLabelLocation;
typedef struct _DejaDupConfigLabelLocationClass DejaDupConfigLabelLocationClass;
typedef struct _DejaDupConfigLabelLocationPrivate DejaDupConfigLabelLocationPrivate;
#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 _DejaDupConfigLabelLocationSetFromConfigData DejaDupConfigLabelLocationSetFromConfigData;

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 _DejaDupConfigLabel {
	DejaDupConfigWidget parent_instance;
	DejaDupConfigLabelPrivate * priv;
	GtkGrid* box;
	GtkLabel* label;
};

struct _DejaDupConfigLabelClass {
	DejaDupConfigWidgetClass parent_class;
	void (*fill_box) (DejaDupConfigLabel* self);
};

struct _DejaDupConfigLabelLocation {
	DejaDupConfigLabel parent_instance;
	DejaDupConfigLabelLocationPrivate * priv;
};

struct _DejaDupConfigLabelLocationClass {
	DejaDupConfigLabelClass parent_class;
};

struct _DejaDupConfigLabelLocationPrivate {
	GtkImage* img;
	DejaDupFilteredSettings* file_root;
	DejaDupFilteredSettings* gdrive_root;
	DejaDupFilteredSettings* s3_root;
	DejaDupFilteredSettings* rackspace_root;
	DejaDupFilteredSettings* openstack_root;
};

struct _DejaDupConfigLabelLocationSetFromConfigData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	DejaDupConfigLabelLocation* self;
	GtkImage* _tmp0_;
	DejaDupBackend* backend;
	DejaDupBackend* _tmp1_;
	gchar* desc;
	DejaDupBackend* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	GtkLabel* _tmp6_;
	const gchar* _tmp7_;
	GIcon* icon;
	DejaDupBackend* _tmp8_;
	GIcon* _tmp9_;
	GIcon* _tmp10_;
	GtkImage* _tmp11_;
	GtkImage* _tmp12_;
	GIcon* _tmp13_;
};


static gpointer deja_dup_config_label_location_parent_class = NULL;

GType deja_dup_config_widget_get_type (void) G_GNUC_CONST;
GType deja_dup_config_label_get_type (void) G_GNUC_CONST;
GType deja_dup_config_label_location_get_type (void) G_GNUC_CONST;
#define DEJA_DUP_CONFIG_LABEL_LOCATION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION, DejaDupConfigLabelLocationPrivate))
enum  {
	DEJA_DUP_CONFIG_LABEL_LOCATION_DUMMY_PROPERTY
};
DejaDupConfigLabelLocation* deja_dup_config_label_location_new (void);
DejaDupConfigLabelLocation* deja_dup_config_label_location_construct (GType object_type);
DejaDupConfigLabel* deja_dup_config_label_new (const gchar* key, const gchar* ns);
DejaDupConfigLabel* deja_dup_config_label_construct (GType object_type, const gchar* key, const gchar* ns);
static void deja_dup_config_label_location_real_fill_box (DejaDupConfigLabel* base);
static void deja_dup_config_label_location_real_set_from_config_data_free (gpointer _data);
static void deja_dup_config_label_location_real_set_from_config (DejaDupConfigWidget* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean deja_dup_config_label_location_real_set_from_config_co (DejaDupConfigLabelLocationSetFromConfigData* _data_);
static GObject * deja_dup_config_label_location_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
void deja_dup_config_label_fill_box (DejaDupConfigLabel* self);
void deja_dup_config_widget_watch_key (DejaDupConfigWidget* self, const gchar* key, DejaDupFilteredSettings* s);
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 void deja_dup_config_label_location_finalize (GObject* obj);


DejaDupConfigLabelLocation* deja_dup_config_label_location_construct (GType object_type) {
	DejaDupConfigLabelLocation * self = NULL;
	self = (DejaDupConfigLabelLocation*) deja_dup_config_label_construct (object_type, NULL, "");
	return self;
}


DejaDupConfigLabelLocation* deja_dup_config_label_location_new (void) {
	return deja_dup_config_label_location_construct (DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION);
}


static void deja_dup_config_label_location_real_fill_box (DejaDupConfigLabel* base) {
	DejaDupConfigLabelLocation * self;
	GtkImage* _tmp0_ = NULL;
	GtkImage* _tmp1_ = NULL;
	GtkGrid* _tmp2_ = NULL;
	GtkImage* _tmp3_ = NULL;
	GtkLabel* _tmp4_ = NULL;
	GtkLabel* _tmp5_ = NULL;
	GtkGrid* _tmp6_ = NULL;
	GtkLabel* _tmp7_ = NULL;
	self = (DejaDupConfigLabelLocation*) base;
	_tmp0_ = self->priv->img;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->img;
	g_object_set ((GtkWidget*) _tmp1_, "expand", FALSE, NULL);
	_tmp2_ = ((DejaDupConfigLabel*) self)->box;
	_tmp3_ = self->priv->img;
	gtk_container_add ((GtkContainer*) _tmp2_, (GtkWidget*) _tmp3_);
	_tmp4_ = ((DejaDupConfigLabel*) self)->label;
	gtk_label_set_xalign (_tmp4_, 0.0f);
	_tmp5_ = ((DejaDupConfigLabel*) self)->label;
	gtk_label_set_ellipsize (_tmp5_, PANGO_ELLIPSIZE_MIDDLE);
	_tmp6_ = ((DejaDupConfigLabel*) self)->box;
	_tmp7_ = ((DejaDupConfigLabel*) self)->label;
	gtk_container_add ((GtkContainer*) _tmp6_, (GtkWidget*) _tmp7_);
}


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


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


static void deja_dup_config_label_location_real_set_from_config (DejaDupConfigWidget* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	DejaDupConfigLabelLocation * self;
	DejaDupConfigLabelLocationSetFromConfigData* _data_;
	DejaDupConfigLabelLocation* _tmp0_ = NULL;
	self = (DejaDupConfigLabelLocation*) base;
	_data_ = g_slice_new0 (DejaDupConfigLabelLocationSetFromConfigData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, deja_dup_config_label_location_real_set_from_config);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, deja_dup_config_label_location_real_set_from_config_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	deja_dup_config_label_location_real_set_from_config_co (_data_);
}


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


static gboolean deja_dup_config_label_location_real_set_from_config_co (DejaDupConfigLabelLocationSetFromConfigData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = _data_->self->priv->img;
	if (_data_->_tmp0_ == NULL) {
		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;
	}
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = deja_dup_backend_get_default ();
	_data_->backend = _data_->_tmp1_;
	_data_->_tmp2_ = NULL;
	_data_->_tmp2_ = _data_->backend;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = deja_dup_backend_get_location_pretty (_data_->_tmp2_);
	_data_->desc = _data_->_tmp3_;
	_data_->_tmp4_ = NULL;
	_data_->_tmp4_ = _data_->desc;
	if (_data_->_tmp4_ == NULL) {
		_data_->_tmp5_ = NULL;
		_data_->_tmp5_ = g_strdup ("");
		_g_free0 (_data_->desc);
		_data_->desc = _data_->_tmp5_;
	}
	_data_->_tmp6_ = NULL;
	_data_->_tmp6_ = ((DejaDupConfigLabel*) _data_->self)->label;
	_data_->_tmp7_ = NULL;
	_data_->_tmp7_ = _data_->desc;
	gtk_label_set_label (_data_->_tmp6_, _data_->_tmp7_);
	_data_->_tmp8_ = NULL;
	_data_->_tmp8_ = _data_->backend;
	_data_->_tmp9_ = NULL;
	_data_->_tmp9_ = deja_dup_backend_get_icon (_data_->_tmp8_);
	_data_->icon = _data_->_tmp9_;
	_data_->_tmp10_ = NULL;
	_data_->_tmp10_ = _data_->icon;
	if (_data_->_tmp10_ == NULL) {
		_data_->_tmp11_ = NULL;
		_data_->_tmp11_ = _data_->self->priv->img;
		gtk_image_set_from_icon_name (_data_->_tmp11_, "folder", GTK_ICON_SIZE_MENU);
	} else {
		_data_->_tmp12_ = NULL;
		_data_->_tmp12_ = _data_->self->priv->img;
		_data_->_tmp13_ = NULL;
		_data_->_tmp13_ = _data_->icon;
		gtk_image_set_from_gicon (_data_->_tmp12_, _data_->_tmp13_, GTK_ICON_SIZE_MENU);
	}
	_g_object_unref0 (_data_->icon);
	_g_free0 (_data_->desc);
	_g_object_unref0 (_data_->backend);
	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 GObject * deja_dup_config_label_location_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	DejaDupConfigLabelLocation * self;
	GtkImage* _tmp0_ = NULL;
	DejaDupFilteredSettings* _tmp1_ = NULL;
	DejaDupFilteredSettings* _tmp2_ = NULL;
	DejaDupFilteredSettings* _tmp3_ = NULL;
	DejaDupFilteredSettings* _tmp4_ = NULL;
	DejaDupFilteredSettings* _tmp5_ = NULL;
	DejaDupFilteredSettings* _tmp6_ = NULL;
	DejaDupFilteredSettings* _tmp7_ = NULL;
	DejaDupFilteredSettings* _tmp8_ = NULL;
	DejaDupFilteredSettings* _tmp9_ = NULL;
	DejaDupFilteredSettings* _tmp10_ = NULL;
	parent_class = G_OBJECT_CLASS (deja_dup_config_label_location_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION, DejaDupConfigLabelLocation);
	_tmp0_ = (GtkImage*) gtk_image_new_from_icon_name ("folder", GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->img);
	self->priv->img = _tmp0_;
	deja_dup_config_label_fill_box ((DejaDupConfigLabel*) self);
	deja_dup_config_widget_watch_key ((DejaDupConfigWidget*) self, DEJA_DUP_BACKEND_KEY, NULL);
	_tmp1_ = deja_dup_get_settings (DEJA_DUP_FILE_ROOT);
	_g_object_unref0 (self->priv->file_root);
	self->priv->file_root = _tmp1_;
	_tmp2_ = self->priv->file_root;
	deja_dup_config_widget_watch_key ((DejaDupConfigWidget*) self, NULL, _tmp2_);
	_tmp3_ = deja_dup_get_settings (DEJA_DUP_GDRIVE_ROOT);
	_g_object_unref0 (self->priv->gdrive_root);
	self->priv->gdrive_root = _tmp3_;
	_tmp4_ = self->priv->gdrive_root;
	deja_dup_config_widget_watch_key ((DejaDupConfigWidget*) self, NULL, _tmp4_);
	_tmp5_ = deja_dup_get_settings (DEJA_DUP_S3_ROOT);
	_g_object_unref0 (self->priv->s3_root);
	self->priv->s3_root = _tmp5_;
	_tmp6_ = self->priv->s3_root;
	deja_dup_config_widget_watch_key ((DejaDupConfigWidget*) self, NULL, _tmp6_);
	_tmp7_ = deja_dup_get_settings (DEJA_DUP_RACKSPACE_ROOT);
	_g_object_unref0 (self->priv->rackspace_root);
	self->priv->rackspace_root = _tmp7_;
	_tmp8_ = self->priv->rackspace_root;
	deja_dup_config_widget_watch_key ((DejaDupConfigWidget*) self, NULL, _tmp8_);
	_tmp9_ = deja_dup_get_settings (DEJA_DUP_OPENSTACK_ROOT);
	_g_object_unref0 (self->priv->openstack_root);
	self->priv->openstack_root = _tmp9_;
	_tmp10_ = self->priv->openstack_root;
	deja_dup_config_widget_watch_key ((DejaDupConfigWidget*) self, NULL, _tmp10_);
	deja_dup_config_widget_set_from_config ((DejaDupConfigWidget*) self, NULL, NULL);
	return obj;
}


static void deja_dup_config_label_location_class_init (DejaDupConfigLabelLocationClass * klass) {
	deja_dup_config_label_location_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DejaDupConfigLabelLocationPrivate));
	((DejaDupConfigLabelClass *) klass)->fill_box = deja_dup_config_label_location_real_fill_box;
	((DejaDupConfigWidgetClass *) klass)->set_from_config = deja_dup_config_label_location_real_set_from_config;
	((DejaDupConfigWidgetClass *) klass)->set_from_config_finish = deja_dup_config_label_location_real_set_from_config_finish;
	G_OBJECT_CLASS (klass)->constructor = deja_dup_config_label_location_constructor;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_config_label_location_finalize;
}


static void deja_dup_config_label_location_instance_init (DejaDupConfigLabelLocation * self) {
	self->priv = DEJA_DUP_CONFIG_LABEL_LOCATION_GET_PRIVATE (self);
}


static void deja_dup_config_label_location_finalize (GObject* obj) {
	DejaDupConfigLabelLocation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_CONFIG_LABEL_LOCATION, DejaDupConfigLabelLocation);
	_g_object_unref0 (self->priv->img);
	_g_object_unref0 (self->priv->file_root);
	_g_object_unref0 (self->priv->gdrive_root);
	_g_object_unref0 (self->priv->s3_root);
	_g_object_unref0 (self->priv->rackspace_root);
	_g_object_unref0 (self->priv->openstack_root);
	G_OBJECT_CLASS (deja_dup_config_label_location_parent_class)->finalize (obj);
}


GType deja_dup_config_label_location_get_type (void) {
	static volatile gsize deja_dup_config_label_location_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_config_label_location_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupConfigLabelLocationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_config_label_location_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupConfigLabelLocation), 0, (GInstanceInitFunc) deja_dup_config_label_location_instance_init, NULL };
		GType deja_dup_config_label_location_type_id;
		deja_dup_config_label_location_type_id = g_type_register_static (DEJA_DUP_TYPE_CONFIG_LABEL, "DejaDupConfigLabelLocation", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_config_label_location_type_id__volatile, deja_dup_config_label_location_type_id);
	}
	return deja_dup_config_label_location_type_id__volatile;
}



