/* gkr-keyring-properties.c generated by valac 0.56.1, the Vala compiler
 * generated from gkr-keyring-properties.vala, do not modify */

/*
 * Seahorse
 *
 * Copyright (C) 2008 Stefan Walter
 *
 * 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 "seahorse-gkr.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <libsecret/secret.h>

enum  {
	SEAHORSE_GKR_KEYRING_PROPERTIES_0_PROPERTY,
	SEAHORSE_GKR_KEYRING_PROPERTIES_KEYRING_PROPERTY,
	SEAHORSE_GKR_KEYRING_PROPERTIES_NUM_PROPERTIES
};
static GParamSpec* seahorse_gkr_keyring_properties_properties[SEAHORSE_GKR_KEYRING_PROPERTIES_NUM_PROPERTIES];
#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_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

struct _SeahorseGkrKeyringPropertiesPrivate {
	SeahorseGkrKeyring* _keyring;
	GtkHeaderBar* header;
	GtkLabel* name_label;
	GtkLabel* created_label;
	GtkImage* keyring_image;
	GtkButton* set_default_button;
	GtkLockButton* lock_button;
};

static gint SeahorseGkrKeyringProperties_private_offset;
static gpointer seahorse_gkr_keyring_properties_parent_class = NULL;

static void seahorse_gkr_keyring_properties_set_created (SeahorseGkrKeyringProperties* self,
                                                  guint64 timestamp);
static void seahorse_gkr_keyring_properties_on_set_default_button_clicked (SeahorseGkrKeyringProperties* self,
                                                                    GtkButton* button);
static void _seahorse_gkr_keyring_properties_on_set_default_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                        gpointer self);
static void seahorse_gkr_keyring_properties_on_change_pw_button_clicked (SeahorseGkrKeyringProperties* self,
                                                                  GtkButton* button);
static void _seahorse_gkr_keyring_properties_on_change_pw_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                      gpointer self);
static GObject * seahorse_gkr_keyring_properties_constructor (GType type,
                                                       guint n_construct_properties,
                                                       GObjectConstructParam * construct_properties);
static void _seahorse_gkr_keyring_properties___lambda25_ (SeahorseGkrKeyringProperties* self,
                                                   GObject* obj,
                                                   GParamSpec* pspec);
static void __seahorse_gkr_keyring_properties___lambda25__g_object_notify (GObject* _sender,
                                                                    GParamSpec* pspec,
                                                                    gpointer self);
static void seahorse_gkr_keyring_properties_finalize (GObject * obj);
static GType seahorse_gkr_keyring_properties_get_type_once (void);
static void _vala_seahorse_gkr_keyring_properties_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static void _vala_seahorse_gkr_keyring_properties_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec);

static inline gpointer
seahorse_gkr_keyring_properties_get_instance_private (SeahorseGkrKeyringProperties* self)
{
	return G_STRUCT_MEMBER_P (self, SeahorseGkrKeyringProperties_private_offset);
}

SeahorseGkrKeyringProperties*
seahorse_gkr_keyring_properties_construct (GType object_type,
                                           SeahorseGkrKeyring* keyring,
                                           GtkWindow* parent)
{
	SeahorseGkrKeyringProperties * self = NULL;
	SeahorseGkrKeyringPermission* perm = NULL;
	SeahorseGkrKeyring* _tmp0_;
	SeahorseGkrKeyringPermission* _tmp1_;
	GtkLockButton* _tmp2_;
	g_return_val_if_fail (keyring != NULL, NULL);
	self = (SeahorseGkrKeyringProperties*) g_object_new (object_type, "keyring", keyring, "transient-for", parent, NULL);
	_tmp0_ = self->priv->_keyring;
	_tmp1_ = seahorse_gkr_keyring_permission_new (_tmp0_);
	perm = _tmp1_;
	_tmp2_ = self->priv->lock_button;
	gtk_lock_button_set_permission (_tmp2_, (GPermission*) perm);
	_g_object_unref0 (perm);
	return self;
}

SeahorseGkrKeyringProperties*
seahorse_gkr_keyring_properties_new (SeahorseGkrKeyring* keyring,
                                     GtkWindow* parent)
{
	return seahorse_gkr_keyring_properties_construct (SEAHORSE_GKR_TYPE_KEYRING_PROPERTIES, keyring, parent);
}

static void
seahorse_gkr_keyring_properties_set_created (SeahorseGkrKeyringProperties* self,
                                             guint64 timestamp)
{
	GDateTime* datetime = NULL;
	GDateTime* _tmp1_;
	GtkLabel* _tmp2_;
	GDateTime* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	if (timestamp == ((guint64) 0)) {
		GtkLabel* _tmp0_;
		_tmp0_ = self->priv->created_label;
		gtk_label_set_label (_tmp0_, _ ("Unknown date"));
		return;
	}
	_tmp1_ = g_date_time_new_from_unix_utc ((gint64) timestamp);
	datetime = _tmp1_;
	_tmp2_ = self->priv->created_label;
	_tmp3_ = datetime;
	_tmp4_ = g_date_time_format (_tmp3_, "%x");
	_tmp5_ = _tmp4_;
	gtk_label_set_label (_tmp2_, _tmp5_);
	_g_free0 (_tmp5_);
	_g_date_time_unref0 (datetime);
}

static void
seahorse_gkr_keyring_properties_on_set_default_button_clicked (SeahorseGkrKeyringProperties* self,
                                                               GtkButton* button)
{
	SeahorseGkrKeyring* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	_tmp0_ = self->priv->_keyring;
	seahorse_gkr_keyring_set_as_default (_tmp0_);
}

static void
_seahorse_gkr_keyring_properties_on_set_default_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                   gpointer self)
{
	seahorse_gkr_keyring_properties_on_set_default_button_clicked ((SeahorseGkrKeyringProperties*) self, _sender);
}

static void
seahorse_gkr_keyring_properties_on_change_pw_button_clicked (SeahorseGkrKeyringProperties* self,
                                                             GtkButton* button)
{
	SeahorseGkrKeyring* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	_tmp0_ = self->priv->_keyring;
	seahorse_gkr_keyring_change_password (_tmp0_);
}

static void
_seahorse_gkr_keyring_properties_on_change_pw_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                 gpointer self)
{
	seahorse_gkr_keyring_properties_on_change_pw_button_clicked ((SeahorseGkrKeyringProperties*) self, _sender);
}

SeahorseGkrKeyring*
seahorse_gkr_keyring_properties_get_keyring (SeahorseGkrKeyringProperties* self)
{
	SeahorseGkrKeyring* result;
	SeahorseGkrKeyring* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_keyring;
	result = _tmp0_;
	return result;
}

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

static void
seahorse_gkr_keyring_properties_set_keyring (SeahorseGkrKeyringProperties* self,
                                             SeahorseGkrKeyring* value)
{
	SeahorseGkrKeyring* old_value;
	g_return_if_fail (self != NULL);
	old_value = seahorse_gkr_keyring_properties_get_keyring (self);
	if (old_value != value) {
		SeahorseGkrKeyring* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_keyring);
		self->priv->_keyring = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, seahorse_gkr_keyring_properties_properties[SEAHORSE_GKR_KEYRING_PROPERTIES_KEYRING_PROPERTY]);
	}
}

static void
_seahorse_gkr_keyring_properties___lambda25_ (SeahorseGkrKeyringProperties* self,
                                              GObject* obj,
                                              GParamSpec* pspec)
{
	SeahorseGkrKeyring* _tmp0_;
	guint64 _tmp1_;
	guint64 _tmp2_;
	g_return_if_fail (obj != NULL);
	g_return_if_fail (pspec != NULL);
	_tmp0_ = self->priv->_keyring;
	g_object_get ((SecretCollection*) _tmp0_, "created", &_tmp1_, NULL);
	_tmp2_ = _tmp1_;
	seahorse_gkr_keyring_properties_set_created (self, _tmp2_);
}

static void
__seahorse_gkr_keyring_properties___lambda25__g_object_notify (GObject* _sender,
                                                               GParamSpec* pspec,
                                                               gpointer self)
{
	_seahorse_gkr_keyring_properties___lambda25_ ((SeahorseGkrKeyringProperties*) self, _sender, pspec);
}

static GObject *
seahorse_gkr_keyring_properties_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SeahorseGkrKeyringProperties * self;
	SeahorseGkrKeyring* _tmp0_;
	GtkHeaderBar* _tmp1_;
	SeahorseGkrKeyring* _tmp2_;
	GtkLabel* _tmp3_;
	SeahorseGkrKeyring* _tmp4_;
	GtkImage* _tmp5_;
	SeahorseGkrKeyring* _tmp6_;
	guint64 _tmp7_;
	guint64 _tmp8_;
	SeahorseGkrKeyring* _tmp9_;
	SeahorseGkrKeyring* _tmp10_;
	GtkButton* _tmp11_;
	parent_class = G_OBJECT_CLASS (seahorse_gkr_keyring_properties_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SEAHORSE_GKR_TYPE_KEYRING_PROPERTIES, SeahorseGkrKeyringProperties);
	g_object_set ((GtkDialog*) self, "use-header-bar", 1, NULL);
	_tmp0_ = self->priv->_keyring;
	_tmp1_ = self->priv->header;
	g_object_bind_property_with_closures ((GObject*) _tmp0_, "label", (GObject*) _tmp1_, "subtitle", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp2_ = self->priv->_keyring;
	_tmp3_ = self->priv->name_label;
	g_object_bind_property_with_closures ((GObject*) _tmp2_, "label", (GObject*) _tmp3_, "label", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp4_ = self->priv->_keyring;
	_tmp5_ = self->priv->keyring_image;
	g_object_bind_property_with_closures ((GObject*) _tmp4_, "icon", (GObject*) _tmp5_, "gicon", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp6_ = self->priv->_keyring;
	g_object_get ((SecretCollection*) _tmp6_, "created", &_tmp7_, NULL);
	_tmp8_ = _tmp7_;
	seahorse_gkr_keyring_properties_set_created (self, _tmp8_);
	_tmp9_ = self->priv->_keyring;
	g_signal_connect_object ((GObject*) _tmp9_, "notify::created", (GCallback) __seahorse_gkr_keyring_properties___lambda25__g_object_notify, self, 0);
	_tmp10_ = self->priv->_keyring;
	_tmp11_ = self->priv->set_default_button;
	g_object_bind_property_with_closures ((GObject*) _tmp10_, "is-default", (GObject*) _tmp11_, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	return obj;
}

static void
seahorse_gkr_keyring_properties_class_init (SeahorseGkrKeyringPropertiesClass * klass,
                                            gpointer klass_data)
{
	seahorse_gkr_keyring_properties_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SeahorseGkrKeyringProperties_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_seahorse_gkr_keyring_properties_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_seahorse_gkr_keyring_properties_set_property;
	G_OBJECT_CLASS (klass)->constructor = seahorse_gkr_keyring_properties_constructor;
	G_OBJECT_CLASS (klass)->finalize = seahorse_gkr_keyring_properties_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_GKR_KEYRING_PROPERTIES_KEYRING_PROPERTY, seahorse_gkr_keyring_properties_properties[SEAHORSE_GKR_KEYRING_PROPERTIES_KEYRING_PROPERTY] = g_param_spec_object ("keyring", "keyring", "keyring", SEAHORSE_GKR_TYPE_KEYRING, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Seahorse/seahorse-gkr-keyring.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "header", FALSE, SeahorseGkrKeyringProperties_private_offset + G_STRUCT_OFFSET (SeahorseGkrKeyringPropertiesPrivate, header));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "name_label", FALSE, SeahorseGkrKeyringProperties_private_offset + G_STRUCT_OFFSET (SeahorseGkrKeyringPropertiesPrivate, name_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "created_label", FALSE, SeahorseGkrKeyringProperties_private_offset + G_STRUCT_OFFSET (SeahorseGkrKeyringPropertiesPrivate, created_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "keyring_image", FALSE, SeahorseGkrKeyringProperties_private_offset + G_STRUCT_OFFSET (SeahorseGkrKeyringPropertiesPrivate, keyring_image));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "set_default_button", FALSE, SeahorseGkrKeyringProperties_private_offset + G_STRUCT_OFFSET (SeahorseGkrKeyringPropertiesPrivate, set_default_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "lock_button", FALSE, SeahorseGkrKeyringProperties_private_offset + G_STRUCT_OFFSET (SeahorseGkrKeyringPropertiesPrivate, lock_button));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_set_default_button_clicked", G_CALLBACK(_seahorse_gkr_keyring_properties_on_set_default_button_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_change_pw_button_clicked", G_CALLBACK(_seahorse_gkr_keyring_properties_on_change_pw_button_clicked_gtk_button_clicked));
}

static void
seahorse_gkr_keyring_properties_instance_init (SeahorseGkrKeyringProperties * self,
                                               gpointer klass)
{
	self->priv = seahorse_gkr_keyring_properties_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
seahorse_gkr_keyring_properties_finalize (GObject * obj)
{
	SeahorseGkrKeyringProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SEAHORSE_GKR_TYPE_KEYRING_PROPERTIES, SeahorseGkrKeyringProperties);
	_g_object_unref0 (self->priv->_keyring);
	G_OBJECT_CLASS (seahorse_gkr_keyring_properties_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
seahorse_gkr_keyring_properties_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SeahorseGkrKeyringPropertiesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_gkr_keyring_properties_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorseGkrKeyringProperties), 0, (GInstanceInitFunc) seahorse_gkr_keyring_properties_instance_init, NULL };
	GType seahorse_gkr_keyring_properties_type_id;
	seahorse_gkr_keyring_properties_type_id = g_type_register_static (gtk_dialog_get_type (), "SeahorseGkrKeyringProperties", &g_define_type_info, 0);
	SeahorseGkrKeyringProperties_private_offset = g_type_add_instance_private (seahorse_gkr_keyring_properties_type_id, sizeof (SeahorseGkrKeyringPropertiesPrivate));
	return seahorse_gkr_keyring_properties_type_id;
}

GType
seahorse_gkr_keyring_properties_get_type (void)
{
	static volatile gsize seahorse_gkr_keyring_properties_type_id__once = 0;
	if (g_once_init_enter (&seahorse_gkr_keyring_properties_type_id__once)) {
		GType seahorse_gkr_keyring_properties_type_id;
		seahorse_gkr_keyring_properties_type_id = seahorse_gkr_keyring_properties_get_type_once ();
		g_once_init_leave (&seahorse_gkr_keyring_properties_type_id__once, seahorse_gkr_keyring_properties_type_id);
	}
	return seahorse_gkr_keyring_properties_type_id__once;
}

static void
_vala_seahorse_gkr_keyring_properties_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	SeahorseGkrKeyringProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SEAHORSE_GKR_TYPE_KEYRING_PROPERTIES, SeahorseGkrKeyringProperties);
	switch (property_id) {
		case SEAHORSE_GKR_KEYRING_PROPERTIES_KEYRING_PROPERTY:
		g_value_set_object (value, seahorse_gkr_keyring_properties_get_keyring (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_seahorse_gkr_keyring_properties_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec)
{
	SeahorseGkrKeyringProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SEAHORSE_GKR_TYPE_KEYRING_PROPERTIES, SeahorseGkrKeyringProperties);
	switch (property_id) {
		case SEAHORSE_GKR_KEYRING_PROPERTIES_KEYRING_PROPERTY:
		seahorse_gkr_keyring_properties_set_keyring (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

