/* unified-privacy-history.c generated by valac 0.20.1, the Vala compiler
 * generated from unified-privacy-history.vala, do not modify */

/* -*- Mode: vala; tab-width: 4; intend-tabs-mode: t -*- */
/* alm
 *
 * Copyright (C) 2012 Seif Lotfy <seif@lotfy.com>
 * Copyright (C) 2012 Manish Sinha <manishsinha@ubuntu.com>
 * Copyright (C) 2012 Intel Corp.
 *               Authored by: Seif Lotfy <seif.lotfy@collabora.co.uk>
 *
alm is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 * 
 * alm 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 Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.";
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <zeitgeist-datamodel.h>
#include <gdk/gdk.h>


#define ALM_TYPE_CALENDAR_DIALOG (alm_calendar_dialog_get_type ())
#define ALM_CALENDAR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ALM_TYPE_CALENDAR_DIALOG, AlmCalendarDialog))
#define ALM_CALENDAR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ALM_TYPE_CALENDAR_DIALOG, AlmCalendarDialogClass))
#define ALM_IS_CALENDAR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ALM_TYPE_CALENDAR_DIALOG))
#define ALM_IS_CALENDAR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ALM_TYPE_CALENDAR_DIALOG))
#define ALM_CALENDAR_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ALM_TYPE_CALENDAR_DIALOG, AlmCalendarDialogClass))

typedef struct _AlmCalendarDialog AlmCalendarDialog;
typedef struct _AlmCalendarDialogClass AlmCalendarDialogClass;
typedef struct _AlmCalendarDialogPrivate AlmCalendarDialogPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define ALM_TYPE_CALENDAR_WIDGET (alm_calendar_widget_get_type ())
#define ALM_CALENDAR_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ALM_TYPE_CALENDAR_WIDGET, AlmCalendarWidget))
#define ALM_CALENDAR_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ALM_TYPE_CALENDAR_WIDGET, AlmCalendarWidgetClass))
#define ALM_IS_CALENDAR_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ALM_TYPE_CALENDAR_WIDGET))
#define ALM_IS_CALENDAR_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ALM_TYPE_CALENDAR_WIDGET))
#define ALM_CALENDAR_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ALM_TYPE_CALENDAR_WIDGET, AlmCalendarWidgetClass))

typedef struct _AlmCalendarWidget AlmCalendarWidget;
typedef struct _AlmCalendarWidgetClass AlmCalendarWidgetClass;
typedef struct _AlmCalendarWidgetPrivate AlmCalendarWidgetPrivate;
typedef struct _Block2Data Block2Data;
#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)))
typedef struct _Block3Data Block3Data;

struct _AlmCalendarDialog {
	GtkDialog parent_instance;
	AlmCalendarDialogPrivate * priv;
};

struct _AlmCalendarDialogClass {
	GtkDialogClass parent_class;
};

struct _AlmCalendarDialogPrivate {
	GtkCalendar* calendar;
};

struct _AlmCalendarWidget {
	GtkGrid parent_instance;
	AlmCalendarWidgetPrivate * priv;
};

struct _AlmCalendarWidgetClass {
	GtkGridClass parent_class;
};

struct _AlmCalendarWidgetPrivate {
	GtkEntry* start_entry;
	GtkEntry* end_entry;
	AlmCalendarDialog* start_dialog;
	AlmCalendarDialog* end_dialog;
	GtkButton* button;
	GtkLabel* invalid_label;
};

struct _Block2Data {
	int _ref_count_;
	AlmCalendarWidget * self;
	GtkButton* start_button;
	GtkButton* end_button;
};

struct _Block3Data {
	int _ref_count_;
	AlmCalendarWidget * self;
	GtkWidget* widget;
	GtkEntry* entry;
	AlmCalendarDialog* dialog;
};


static gpointer alm_calendar_dialog_parent_class = NULL;
static gpointer alm_calendar_widget_parent_class = NULL;

GType alm_calendar_dialog_get_type (void) G_GNUC_CONST;
#define ALM_CALENDAR_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ALM_TYPE_CALENDAR_DIALOG, AlmCalendarDialogPrivate))
enum  {
	ALM_CALENDAR_DIALOG_DUMMY_PROPERTY
};
AlmCalendarDialog* alm_calendar_dialog_new (void);
AlmCalendarDialog* alm_calendar_dialog_construct (GType object_type);
GtkCalendar* alm_calendar_dialog_get_calendar_widget (AlmCalendarDialog* self);
static void alm_calendar_dialog_finalize (GObject* obj);
GType alm_calendar_widget_get_type (void) G_GNUC_CONST;
#define ALM_CALENDAR_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ALM_TYPE_CALENDAR_WIDGET, AlmCalendarWidgetPrivate))
enum  {
	ALM_CALENDAR_WIDGET_DUMMY_PROPERTY
};
AlmCalendarWidget* alm_calendar_widget_new (GtkButton* button);
AlmCalendarWidget* alm_calendar_widget_construct (GType object_type, GtkButton* button);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void __lambda6_ (Block2Data* _data2_);
void alm_calendar_widget_on_clicked (AlmCalendarWidget* self, GtkWidget* widget, GtkEntry* entry, AlmCalendarDialog* dialog);
static void ___lambda6__gtk_button_clicked (GtkButton* _sender, gpointer self);
static void __lambda9_ (Block2Data* _data2_);
static void ___lambda9__gtk_button_clicked (GtkButton* _sender, gpointer self);
void alm_calendar_widget_set_up_calendar (AlmCalendarWidget* self, GtkButton* widget, GtkEntry* entry, AlmCalendarDialog* dialog);
ZeitgeistTimeRange* alm_calendar_widget_get_range (AlmCalendarWidget* self);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static gboolean __lambda7_ (Block3Data* _data3_, GtkWidget* w, GdkEventFocus* e);
static gboolean ___lambda7__gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self);
static void __lambda8_ (Block3Data* _data3_);
static void ___lambda8__gtk_calendar_day_selected_double_click (GtkCalendar* _sender, gpointer self);
static void alm_calendar_widget_finalize (GObject* obj);


AlmCalendarDialog* alm_calendar_dialog_construct (GType object_type) {
	AlmCalendarDialog * self = NULL;
	GtkCalendar* _tmp0_;
	GtkBox* _tmp1_ = NULL;
	GtkCalendar* _tmp2_;
	GValue _tmp3_ = {0};
	self = (AlmCalendarDialog*) g_object_new (object_type, NULL);
	_tmp0_ = (GtkCalendar*) gtk_calendar_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->calendar);
	self->priv->calendar = _tmp0_;
	_tmp1_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp2_ = self->priv->calendar;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GTK_TYPE_CONTAINER, GtkContainer), (GtkWidget*) _tmp2_);
	gtk_window_set_decorated ((GtkWindow*) self, FALSE);
	gtk_window_set_position ((GtkWindow*) self, 0);
	g_value_init (&_tmp3_, G_TYPE_BOOLEAN);
	g_value_set_boolean (&_tmp3_, TRUE);
	g_object_set_property ((GObject*) self, "skip-taskbar-hint", &_tmp3_);
	G_IS_VALUE (&_tmp3_) ? (g_value_unset (&_tmp3_), NULL) : NULL;
	return self;
}


AlmCalendarDialog* alm_calendar_dialog_new (void) {
	return alm_calendar_dialog_construct (ALM_TYPE_CALENDAR_DIALOG);
}


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


GtkCalendar* alm_calendar_dialog_get_calendar_widget (AlmCalendarDialog* self) {
	GtkCalendar* result = NULL;
	GtkCalendar* _tmp0_;
	GtkCalendar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->calendar;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}


static void alm_calendar_dialog_class_init (AlmCalendarDialogClass * klass) {
	alm_calendar_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (AlmCalendarDialogPrivate));
	G_OBJECT_CLASS (klass)->finalize = alm_calendar_dialog_finalize;
}


static void alm_calendar_dialog_instance_init (AlmCalendarDialog * self) {
	self->priv = ALM_CALENDAR_DIALOG_GET_PRIVATE (self);
}


static void alm_calendar_dialog_finalize (GObject* obj) {
	AlmCalendarDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ALM_TYPE_CALENDAR_DIALOG, AlmCalendarDialog);
	_g_object_unref0 (self->priv->calendar);
	G_OBJECT_CLASS (alm_calendar_dialog_parent_class)->finalize (obj);
}


GType alm_calendar_dialog_get_type (void) {
	static volatile gsize alm_calendar_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&alm_calendar_dialog_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (AlmCalendarDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) alm_calendar_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AlmCalendarDialog), 0, (GInstanceInitFunc) alm_calendar_dialog_instance_init, NULL };
		GType alm_calendar_dialog_type_id;
		alm_calendar_dialog_type_id = g_type_register_static (GTK_TYPE_DIALOG, "AlmCalendarDialog", &g_define_type_info, 0);
		g_once_init_leave (&alm_calendar_dialog_type_id__volatile, alm_calendar_dialog_type_id);
	}
	return alm_calendar_dialog_type_id__volatile;
}


static Block2Data* block2_data_ref (Block2Data* _data2_) {
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}


static void block2_data_unref (void * _userdata_) {
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		AlmCalendarWidget * self;
		self = _data2_->self;
		_g_object_unref0 (_data2_->end_button);
		_g_object_unref0 (_data2_->start_button);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}


static void __lambda6_ (Block2Data* _data2_) {
	AlmCalendarWidget * self;
	GtkEntry* _tmp0_;
	AlmCalendarDialog* _tmp1_;
	self = _data2_->self;
	_tmp0_ = self->priv->start_entry;
	_tmp1_ = self->priv->start_dialog;
	alm_calendar_widget_on_clicked (self, (GtkWidget*) _data2_->start_button, _tmp0_, _tmp1_);
}


static void ___lambda6__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	__lambda6_ (self);
}


static void __lambda9_ (Block2Data* _data2_) {
	AlmCalendarWidget * self;
	GtkEntry* _tmp0_;
	AlmCalendarDialog* _tmp1_;
	self = _data2_->self;
	_tmp0_ = self->priv->end_entry;
	_tmp1_ = self->priv->end_dialog;
	alm_calendar_widget_on_clicked (self, (GtkWidget*) _data2_->end_button, _tmp0_, _tmp1_);
}


static void ___lambda9__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	__lambda9_ (self);
}


AlmCalendarWidget* alm_calendar_widget_construct (GType object_type, GtkButton* button) {
	AlmCalendarWidget * self = NULL;
	Block2Data* _data2_;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	AlmCalendarDialog* _tmp2_;
	AlmCalendarDialog* _tmp3_;
	GtkBox* _tmp4_;
	GtkBox* box1;
	GtkEntry* _tmp5_;
	GtkButton* _tmp6_;
	GtkArrow* _tmp7_;
	GtkArrow* arrow1;
	GtkEntry* _tmp8_;
	GtkEntry* _tmp9_;
	GtkEntry* _tmp10_;
	GtkBox* _tmp11_;
	GtkBox* box2;
	GtkEntry* _tmp12_;
	GtkButton* _tmp13_;
	GtkArrow* _tmp14_;
	GtkArrow* arrow2;
	GtkEntry* _tmp15_;
	GtkEntry* _tmp16_;
	GtkEntry* _tmp17_;
	GtkLabel* _tmp18_;
	GtkLabel* start_label;
	const gchar* _tmp19_ = NULL;
	GtkLabel* _tmp20_;
	GtkLabel* end_label;
	const gchar* _tmp21_ = NULL;
	GtkLabel* _tmp22_;
	GtkLabel* _tmp23_;
	const gchar* _tmp24_ = NULL;
	gchar* _tmp25_ = NULL;
	gchar* _tmp26_;
	GtkEntry* _tmp27_;
	AlmCalendarDialog* _tmp28_;
	GtkEntry* _tmp29_;
	AlmCalendarDialog* _tmp30_;
	g_return_val_if_fail (button != NULL, NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	self = (AlmCalendarWidget*) g_object_new (object_type, NULL);
	_data2_->self = g_object_ref (self);
	_tmp0_ = button;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->button);
	self->priv->button = _tmp1_;
	_tmp2_ = alm_calendar_dialog_new ();
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->start_dialog);
	self->priv->start_dialog = _tmp2_;
	_tmp3_ = alm_calendar_dialog_new ();
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->end_dialog);
	self->priv->end_dialog = _tmp3_;
	gtk_grid_set_row_spacing ((GtkGrid*) self, (guint) 10);
	gtk_grid_set_column_spacing ((GtkGrid*) self, (guint) 15);
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp4_);
	box1 = _tmp4_;
	_tmp5_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->start_entry);
	self->priv->start_entry = _tmp5_;
	_tmp6_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp6_);
	_data2_->start_button = _tmp6_;
	_tmp7_ = (GtkArrow*) gtk_arrow_new (GTK_ARROW_DOWN, 0);
	g_object_ref_sink (_tmp7_);
	arrow1 = _tmp7_;
	gtk_container_add ((GtkContainer*) _data2_->start_button, (GtkWidget*) arrow1);
	_tmp8_ = self->priv->start_entry;
	gtk_editable_set_editable ((GtkEditable*) _tmp8_, FALSE);
	_tmp9_ = self->priv->start_entry;
	gtk_widget_set_size_request ((GtkWidget*) _tmp9_, 100, -1);
	_tmp10_ = self->priv->start_entry;
	gtk_box_pack_start (box1, (GtkWidget*) _tmp10_, TRUE, TRUE, (guint) 0);
	gtk_box_pack_start (box1, (GtkWidget*) _data2_->start_button, TRUE, TRUE, (guint) 0);
	g_signal_connect_data (_data2_->start_button, "clicked", (GCallback) ___lambda6__gtk_button_clicked, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp11_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp11_);
	box2 = _tmp11_;
	_tmp12_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->end_entry);
	self->priv->end_entry = _tmp12_;
	_tmp13_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp13_);
	_data2_->end_button = _tmp13_;
	_tmp14_ = (GtkArrow*) gtk_arrow_new (GTK_ARROW_DOWN, 0);
	g_object_ref_sink (_tmp14_);
	arrow2 = _tmp14_;
	gtk_container_add ((GtkContainer*) _data2_->end_button, (GtkWidget*) arrow2);
	_tmp15_ = self->priv->end_entry;
	gtk_editable_set_editable ((GtkEditable*) _tmp15_, FALSE);
	_tmp16_ = self->priv->end_entry;
	gtk_widget_set_size_request ((GtkWidget*) _tmp16_, 100, -1);
	_tmp17_ = self->priv->end_entry;
	gtk_box_pack_start (box2, (GtkWidget*) _tmp17_, TRUE, TRUE, (guint) 0);
	gtk_box_pack_start (box2, (GtkWidget*) _data2_->end_button, TRUE, TRUE, (guint) 0);
	g_signal_connect_data (_data2_->end_button, "clicked", (GCallback) ___lambda9__gtk_button_clicked, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp18_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp18_);
	start_label = _tmp18_;
	_tmp19_ = _ ("From:");
	gtk_label_set_markup (start_label, _tmp19_);
	gtk_misc_set_alignment ((GtkMisc*) start_label, (gfloat) 1, (gfloat) (0 / 5));
	_tmp20_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp20_);
	end_label = _tmp20_;
	_tmp21_ = _ ("To:");
	gtk_label_set_markup (end_label, _tmp21_);
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) box1, 1, 0, 1, 1);
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) end_label, 2, 0, 1, 1);
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) box2, 3, 0, 1, 1);
	_tmp22_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp22_);
	_g_object_unref0 (self->priv->invalid_label);
	self->priv->invalid_label = _tmp22_;
	_tmp23_ = self->priv->invalid_label;
	_tmp24_ = _ ("Invalid Timerange");
	_tmp25_ = g_strdup_printf ("<span color='red'><b>%s</b></span>", _tmp24_);
	_tmp26_ = _tmp25_;
	gtk_label_set_markup (_tmp23_, _tmp26_);
	_g_free0 (_tmp26_);
	_tmp27_ = self->priv->start_entry;
	_tmp28_ = self->priv->start_dialog;
	alm_calendar_widget_set_up_calendar (self, _data2_->start_button, _tmp27_, _tmp28_);
	_tmp29_ = self->priv->end_entry;
	_tmp30_ = self->priv->end_dialog;
	alm_calendar_widget_set_up_calendar (self, _data2_->end_button, _tmp29_, _tmp30_);
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (end_label);
	_g_object_unref0 (start_label);
	_g_object_unref0 (arrow2);
	_g_object_unref0 (box2);
	_g_object_unref0 (arrow1);
	_g_object_unref0 (box1);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return self;
}


AlmCalendarWidget* alm_calendar_widget_new (GtkButton* button) {
	return alm_calendar_widget_construct (ALM_TYPE_CALENDAR_WIDGET, button);
}


ZeitgeistTimeRange* alm_calendar_widget_get_range (AlmCalendarWidget* self) {
	ZeitgeistTimeRange* result = NULL;
	AlmCalendarDialog* _tmp0_;
	GtkCalendar* _tmp1_ = NULL;
	GtkCalendar* calendar;
	guint year = 0U;
	guint month = 0U;
	guint day = 0U;
	GtkCalendar* _tmp2_;
	guint _tmp3_ = 0U;
	guint _tmp4_ = 0U;
	guint _tmp5_ = 0U;
	guint _tmp6_;
	guint _tmp7_;
	guint _tmp8_;
	GDateTime* _tmp9_;
	GDateTime* date;
	GDateTime* _tmp10_;
	gint64 _tmp11_ = 0LL;
	gint64 start;
	AlmCalendarDialog* _tmp12_;
	GtkCalendar* _tmp13_ = NULL;
	GtkCalendar* _tmp14_;
	guint _tmp15_ = 0U;
	guint _tmp16_ = 0U;
	guint _tmp17_ = 0U;
	guint _tmp18_;
	guint _tmp19_;
	guint _tmp20_;
	GDateTime* _tmp21_;
	GDateTime* _tmp22_;
	gint64 _tmp23_ = 0LL;
	gint64 end;
	gint64 _tmp24_;
	gint64 _tmp25_;
	gint64 _tmp33_;
	gint64 _tmp34_;
	ZeitgeistTimeRange* _tmp35_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->start_dialog;
	_tmp1_ = alm_calendar_dialog_get_calendar_widget (_tmp0_);
	calendar = _tmp1_;
	_tmp2_ = calendar;
	gtk_calendar_get_date (_tmp2_, &_tmp3_, &_tmp4_, &_tmp5_);
	year = _tmp3_;
	month = _tmp4_;
	day = _tmp5_;
	_tmp6_ = year;
	_tmp7_ = month;
	_tmp8_ = day;
	_tmp9_ = g_date_time_new_local ((gint) _tmp6_, ((gint) _tmp7_) + 1, (gint) _tmp8_, 0, 0, (gdouble) 0);
	date = _tmp9_;
	_tmp10_ = date;
	_tmp11_ = g_date_time_to_unix (_tmp10_);
	start = _tmp11_ * 1000;
	_tmp12_ = self->priv->end_dialog;
	_tmp13_ = alm_calendar_dialog_get_calendar_widget (_tmp12_);
	_g_object_unref0 (calendar);
	calendar = _tmp13_;
	_tmp14_ = calendar;
	gtk_calendar_get_date (_tmp14_, &_tmp15_, &_tmp16_, &_tmp17_);
	year = _tmp15_;
	month = _tmp16_;
	day = _tmp17_;
	_tmp18_ = year;
	_tmp19_ = month;
	_tmp20_ = day;
	_tmp21_ = g_date_time_new_local ((gint) _tmp18_, ((gint) _tmp19_) + 1, (gint) _tmp20_, 0, 0, (gdouble) 0);
	_g_date_time_unref0 (date);
	date = _tmp21_;
	_tmp22_ = date;
	_tmp23_ = g_date_time_to_unix (_tmp22_);
	end = _tmp23_ * 1000;
	_tmp24_ = start;
	_tmp25_ = end;
	if (_tmp24_ > _tmp25_) {
		GtkButton* _tmp26_;
		GtkLabel* _tmp27_;
		GtkWidget* _tmp28_ = NULL;
		GtkLabel* _tmp30_;
		_tmp26_ = self->priv->button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp26_, FALSE);
		_tmp27_ = self->priv->invalid_label;
		_tmp28_ = gtk_widget_get_parent ((GtkWidget*) _tmp27_);
		if (_tmp28_ == NULL) {
			GtkLabel* _tmp29_;
			_tmp29_ = self->priv->invalid_label;
			gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp29_, 2, 0, 1, 2);
		}
		_tmp30_ = self->priv->invalid_label;
		gtk_widget_show ((GtkWidget*) _tmp30_);
	} else {
		GtkButton* _tmp31_;
		GtkLabel* _tmp32_;
		_tmp31_ = self->priv->button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp31_, TRUE);
		_tmp32_ = self->priv->invalid_label;
		gtk_widget_hide ((GtkWidget*) _tmp32_);
	}
	_tmp33_ = start;
	_tmp34_ = end;
	_tmp35_ = zeitgeist_time_range_new (_tmp33_, _tmp34_);
	result = _tmp35_;
	_g_date_time_unref0 (date);
	_g_object_unref0 (calendar);
	return result;
}


void alm_calendar_widget_set_up_calendar (AlmCalendarWidget* self, GtkButton* widget, GtkEntry* entry, AlmCalendarDialog* dialog) {
	AlmCalendarDialog* _tmp0_;
	GtkCalendar* _tmp1_ = NULL;
	GtkCalendar* calendar;
	guint year = 0U;
	guint month = 0U;
	guint day = 0U;
	guint _tmp2_ = 0U;
	guint _tmp3_ = 0U;
	guint _tmp4_ = 0U;
	GDateTime* _tmp5_;
	GDateTime* date;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* date_string;
	GtkEntry* _tmp8_;
	GtkButton* _tmp9_;
	AlmCalendarDialog* _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	g_return_if_fail (entry != NULL);
	g_return_if_fail (dialog != NULL);
	_tmp0_ = dialog;
	_tmp1_ = alm_calendar_dialog_get_calendar_widget (_tmp0_);
	calendar = _tmp1_;
	gtk_calendar_get_date (calendar, &_tmp2_, &_tmp3_, &_tmp4_);
	year = _tmp2_;
	month = _tmp3_;
	day = _tmp4_;
	_tmp5_ = g_date_time_new_local ((gint) year, ((gint) month) + 1, (gint) day, 0, 0, (gdouble) 0);
	date = _tmp5_;
	_tmp6_ = _ ("%d %B %Y");
	_tmp7_ = g_date_time_format (date, _tmp6_);
	date_string = _tmp7_;
	_tmp8_ = entry;
	gtk_entry_set_text (_tmp8_, date_string);
	_tmp9_ = widget;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp9_, TRUE);
	_tmp10_ = dialog;
	gtk_widget_hide ((GtkWidget*) _tmp10_);
	_g_free0 (date_string);
	_g_date_time_unref0 (date);
	_g_object_unref0 (calendar);
}


static Block3Data* block3_data_ref (Block3Data* _data3_) {
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}


static void block3_data_unref (void * _userdata_) {
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		AlmCalendarWidget * self;
		self = _data3_->self;
		_g_object_unref0 (_data3_->widget);
		_g_object_unref0 (_data3_->entry);
		_g_object_unref0 (_data3_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}


static gboolean __lambda7_ (Block3Data* _data3_, GtkWidget* w, GdkEventFocus* e) {
	AlmCalendarWidget * self;
	gboolean result = FALSE;
	AlmCalendarDialog* _tmp0_;
	GtkWidget* _tmp1_;
	self = _data3_->self;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = _data3_->dialog;
	gtk_widget_hide ((GtkWidget*) _tmp0_);
	_tmp1_ = _data3_->widget;
	gtk_widget_set_sensitive (_tmp1_, TRUE);
	result = FALSE;
	return result;
}


static gboolean ___lambda7__gtk_widget_focus_out_event (GtkWidget* _sender, GdkEventFocus* event, gpointer self) {
	gboolean result;
	result = __lambda7_ (self, _sender, event);
	return result;
}


static void __lambda8_ (Block3Data* _data3_) {
	AlmCalendarWidget * self;
	AlmCalendarDialog* _tmp0_;
	GtkCalendar* _tmp1_ = NULL;
	GtkCalendar* calendar;
	guint year = 0U;
	guint month = 0U;
	guint day = 0U;
	guint _tmp2_ = 0U;
	guint _tmp3_ = 0U;
	guint _tmp4_ = 0U;
	GDateTime* _tmp5_;
	GDateTime* date;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* date_string;
	GtkEntry* _tmp8_;
	GtkWidget* _tmp9_;
	AlmCalendarDialog* _tmp10_;
	ZeitgeistTimeRange* _tmp11_ = NULL;
	ZeitgeistTimeRange* range;
	self = _data3_->self;
	_tmp0_ = _data3_->dialog;
	_tmp1_ = alm_calendar_dialog_get_calendar_widget (_tmp0_);
	calendar = _tmp1_;
	gtk_calendar_get_date (calendar, &_tmp2_, &_tmp3_, &_tmp4_);
	year = _tmp2_;
	month = _tmp3_;
	day = _tmp4_;
	_tmp5_ = g_date_time_new_local ((gint) year, ((gint) month) + 1, (gint) day, 0, 0, (gdouble) 0);
	date = _tmp5_;
	_tmp6_ = _ ("%d %B %Y");
	_tmp7_ = g_date_time_format (date, _tmp6_);
	date_string = _tmp7_;
	_tmp8_ = _data3_->entry;
	gtk_entry_set_text (_tmp8_, date_string);
	_tmp9_ = _data3_->widget;
	gtk_widget_set_sensitive (_tmp9_, TRUE);
	_tmp10_ = _data3_->dialog;
	gtk_widget_hide ((GtkWidget*) _tmp10_);
	_tmp11_ = alm_calendar_widget_get_range (self);
	range = _tmp11_;
	_g_object_unref0 (range);
	_g_free0 (date_string);
	_g_date_time_unref0 (date);
	_g_object_unref0 (calendar);
}


static void ___lambda8__gtk_calendar_day_selected_double_click (GtkCalendar* _sender, gpointer self) {
	__lambda8_ (self);
}


void alm_calendar_widget_on_clicked (AlmCalendarWidget* self, GtkWidget* widget, GtkEntry* entry, AlmCalendarDialog* dialog) {
	Block3Data* _data3_;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkEntry* _tmp2_;
	GtkEntry* _tmp3_;
	AlmCalendarDialog* _tmp4_;
	AlmCalendarDialog* _tmp5_;
	AlmCalendarDialog* _tmp6_;
	GdkWindow* _tmp7_ = NULL;
	GdkWindow* _tmp8_;
	GdkWindow* parent_window;
	gint window_x = 0;
	gint window_y = 0;
	gint _tmp9_ = 0;
	gint _tmp10_ = 0;
	GtkAllocation allocation = {0};
	GtkEntry* _tmp11_;
	GtkAllocation _tmp12_ = {0};
	AlmCalendarDialog* _tmp13_;
	GtkAllocation _tmp14_;
	gint _tmp15_;
	GtkAllocation _tmp16_;
	gint _tmp17_;
	GtkAllocation _tmp18_;
	gint _tmp19_;
	AlmCalendarDialog* _tmp20_;
	GtkAllocation _tmp21_;
	gint _tmp22_;
	AlmCalendarDialog* _tmp23_;
	GtkWidget* _tmp24_;
	AlmCalendarDialog* _tmp25_;
	AlmCalendarDialog* _tmp26_;
	GtkCalendar* _tmp27_ = NULL;
	GtkCalendar* cal;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	g_return_if_fail (entry != NULL);
	g_return_if_fail (dialog != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = widget;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (_data3_->widget);
	_data3_->widget = _tmp1_;
	_tmp2_ = entry;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (_data3_->entry);
	_data3_->entry = _tmp3_;
	_tmp4_ = dialog;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (_data3_->dialog);
	_data3_->dialog = _tmp5_;
	_tmp6_ = _data3_->dialog;
	gtk_widget_show_all ((GtkWidget*) _tmp6_);
	_tmp7_ = gtk_widget_get_parent_window ((GtkWidget*) self);
	_tmp8_ = _g_object_ref0 (_tmp7_);
	parent_window = _tmp8_;
	gdk_window_get_position (parent_window, &_tmp9_, &_tmp10_);
	window_x = _tmp9_;
	window_y = _tmp10_;
	_tmp11_ = _data3_->entry;
	gtk_widget_get_allocation ((GtkWidget*) _tmp11_, &_tmp12_);
	allocation = _tmp12_;
	_tmp13_ = _data3_->dialog;
	_tmp14_ = allocation;
	_tmp15_ = _tmp14_.x;
	_tmp16_ = allocation;
	_tmp17_ = _tmp16_.y;
	_tmp18_ = allocation;
	_tmp19_ = _tmp18_.height;
	gtk_window_move ((GtkWindow*) _tmp13_, window_x + _tmp15_, (window_y + _tmp17_) + _tmp19_);
	_tmp20_ = _data3_->dialog;
	_tmp21_ = allocation;
	_tmp22_ = _tmp21_.width;
	gtk_widget_set_size_request ((GtkWidget*) _tmp20_, _tmp22_, -1);
	_tmp23_ = _data3_->dialog;
	gtk_window_set_resizable ((GtkWindow*) _tmp23_, FALSE);
	_tmp24_ = _data3_->widget;
	gtk_widget_set_sensitive (_tmp24_, FALSE);
	_tmp25_ = _data3_->dialog;
	g_signal_connect_data ((GtkWidget*) _tmp25_, "focus-out-event", (GCallback) ___lambda7__gtk_widget_focus_out_event, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, G_CONNECT_AFTER);
	_tmp26_ = _data3_->dialog;
	_tmp27_ = alm_calendar_dialog_get_calendar_widget (_tmp26_);
	cal = _tmp27_;
	g_signal_connect_data (cal, "day-selected-double-click", (GCallback) ___lambda8__gtk_calendar_day_selected_double_click, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
	_g_object_unref0 (cal);
	_g_object_unref0 (parent_window);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}


static void alm_calendar_widget_class_init (AlmCalendarWidgetClass * klass) {
	alm_calendar_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (AlmCalendarWidgetPrivate));
	G_OBJECT_CLASS (klass)->finalize = alm_calendar_widget_finalize;
}


static void alm_calendar_widget_instance_init (AlmCalendarWidget * self) {
	self->priv = ALM_CALENDAR_WIDGET_GET_PRIVATE (self);
}


static void alm_calendar_widget_finalize (GObject* obj) {
	AlmCalendarWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, ALM_TYPE_CALENDAR_WIDGET, AlmCalendarWidget);
	_g_object_unref0 (self->priv->start_entry);
	_g_object_unref0 (self->priv->end_entry);
	_g_object_unref0 (self->priv->start_dialog);
	_g_object_unref0 (self->priv->end_dialog);
	_g_object_unref0 (self->priv->button);
	_g_object_unref0 (self->priv->invalid_label);
	G_OBJECT_CLASS (alm_calendar_widget_parent_class)->finalize (obj);
}


GType alm_calendar_widget_get_type (void) {
	static volatile gsize alm_calendar_widget_type_id__volatile = 0;
	if (g_once_init_enter (&alm_calendar_widget_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (AlmCalendarWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) alm_calendar_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AlmCalendarWidget), 0, (GInstanceInitFunc) alm_calendar_widget_instance_init, NULL };
		GType alm_calendar_widget_type_id;
		alm_calendar_widget_type_id = g_type_register_static (GTK_TYPE_GRID, "AlmCalendarWidget", &g_define_type_info, 0);
		g_once_init_leave (&alm_calendar_widget_type_id__volatile, alm_calendar_widget_type_id);
	}
	return alm_calendar_widget_type_id__volatile;
}



