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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
    This file is part of Déjà Dup.
    © 2009 Michael Terry <mike@mterry.name>

    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 <gconf/gconf-client.h>
#include <stdlib.h>
#include <string.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 _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _DejaDupConfigWidget {
	GtkEventBox parent_instance;
	DejaDupConfigWidgetPrivate * priv;
	GConfClient* client;
};

struct _DejaDupConfigWidgetClass {
	GtkEventBoxClass parent_class;
	void (*set_from_config) (DejaDupConfigWidget* self);
};

struct _DejaDupConfigLabel {
	DejaDupConfigWidget parent_instance;
	DejaDupConfigLabelPrivate * priv;
	GtkHBox* hbox;
	GtkLabel* label;
};

struct _DejaDupConfigLabelClass {
	DejaDupConfigWidgetClass parent_class;
};


static gpointer deja_dup_config_label_parent_class = NULL;

GType deja_dup_config_widget_get_type (void);
GType deja_dup_config_label_get_type (void);
enum  {
	DEJA_DUP_CONFIG_LABEL_DUMMY_PROPERTY
};
DejaDupConfigLabel* deja_dup_config_label_new (const char* key);
DejaDupConfigLabel* deja_dup_config_label_construct (GType object_type, const char* key);
const char* deja_dup_config_widget_get_key (DejaDupConfigWidget* self);
static void deja_dup_config_label_real_set_from_config (DejaDupConfigWidget* base);
void deja_dup_config_widget_set_from_config (DejaDupConfigWidget* self);
static GObject * deja_dup_config_label_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void deja_dup_config_label_finalize (GObject* obj);



DejaDupConfigLabel* deja_dup_config_label_construct (GType object_type, const char* key) {
	DejaDupConfigLabel * self;
	self = (DejaDupConfigLabel*) g_object_new (object_type, "key", key, NULL);
	return self;
}


DejaDupConfigLabel* deja_dup_config_label_new (const char* key) {
	return deja_dup_config_label_construct (DEJA_DUP_TYPE_CONFIG_LABEL, key);
}


static void deja_dup_config_label_real_set_from_config (DejaDupConfigWidget* base) {
	DejaDupConfigLabel * self;
	GError * _inner_error_;
	char* val;
	self = (DejaDupConfigLabel*) base;
	_inner_error_ = NULL;
	val = NULL;
	{
		char* _tmp0_;
		char* _tmp1_;
		_tmp0_ = gconf_client_get_string (((DejaDupConfigWidget*) self)->client, deja_dup_config_widget_get_key ((DejaDupConfigWidget*) self), &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch9_g_error;
		}
		val = (_tmp1_ = _tmp0_, _g_free0 (val), _tmp1_);
		gtk_label_set_label (self->label, val);
	}
	goto __finally9;
	__catch9_g_error:
	{
		GError * e;
		e = _inner_error_;
		_inner_error_ = NULL;
		{
			g_warning ("ConfigLabel.vala:49: %s\n", e->message);
			_g_error_free0 (e);
		}
	}
	__finally9:
	if (_inner_error_ != NULL) {
		_g_free0 (val);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_g_free0 (val);
}


static GObject * deja_dup_config_label_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	DejaDupConfigLabel * self;
	parent_class = G_OBJECT_CLASS (deja_dup_config_label_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = DEJA_DUP_CONFIG_LABEL (obj);
	{
		GtkLabel* _tmp0_;
		GtkHBox* _tmp1_;
		self->label = (_tmp0_ = g_object_ref_sink ((GtkLabel*) gtk_label_new ("")), _g_object_unref0 (self->label), _tmp0_);
		g_object_set ((GObject*) self->label, "xalign", 0.0f, NULL);
		self->hbox = (_tmp1_ = g_object_ref_sink ((GtkHBox*) gtk_hbox_new (FALSE, 6)), _g_object_unref0 (self->hbox), _tmp1_);
		gtk_box_pack_start ((GtkBox*) self->hbox, (GtkWidget*) self->label, TRUE, TRUE, (guint) 0);
		gtk_container_add ((GtkContainer*) self, (GtkWidget*) self->hbox);
		deja_dup_config_widget_set_from_config ((DejaDupConfigWidget*) self);
	}
	return obj;
}


static void deja_dup_config_label_class_init (DejaDupConfigLabelClass * klass) {
	deja_dup_config_label_parent_class = g_type_class_peek_parent (klass);
	DEJA_DUP_CONFIG_WIDGET_CLASS (klass)->set_from_config = deja_dup_config_label_real_set_from_config;
	G_OBJECT_CLASS (klass)->constructor = deja_dup_config_label_constructor;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_config_label_finalize;
}


static void deja_dup_config_label_instance_init (DejaDupConfigLabel * self) {
}


static void deja_dup_config_label_finalize (GObject* obj) {
	DejaDupConfigLabel * self;
	self = DEJA_DUP_CONFIG_LABEL (obj);
	_g_object_unref0 (self->hbox);
	_g_object_unref0 (self->label);
	G_OBJECT_CLASS (deja_dup_config_label_parent_class)->finalize (obj);
}


GType deja_dup_config_label_get_type (void) {
	static volatile gsize deja_dup_config_label_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_config_label_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupConfigLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_config_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupConfigLabel), 0, (GInstanceInitFunc) deja_dup_config_label_instance_init, NULL };
		GType deja_dup_config_label_type_id;
		deja_dup_config_label_type_id = g_type_register_static (DEJA_DUP_TYPE_CONFIG_WIDGET, "DejaDupConfigLabel", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_config_label_type_id__volatile, deja_dup_config_label_type_id);
	}
	return deja_dup_config_label_type_id__volatile;
}




