/* unified-privacy-history.c generated by valac 0.56.19, 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 <gtk/gtk.h>
#include <glib-object.h>
#include <glib.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>
#include <cairo-gobject.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#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;
enum  {
	ALM_CALENDAR_DIALOG_0_PROPERTY,
	ALM_CALENDAR_DIALOG_NUM_PROPERTIES
};
static GParamSpec* alm_calendar_dialog_properties[ALM_CALENDAR_DIALOG_NUM_PROPERTIES];
#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;
enum  {
	ALM_CALENDAR_WIDGET_0_PROPERTY,
	ALM_CALENDAR_WIDGET_NUM_PROPERTIES
};
static GParamSpec* alm_calendar_widget_properties[ALM_CALENDAR_WIDGET_NUM_PROPERTIES];
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 gint AlmCalendarDialog_private_offset;
static gpointer alm_calendar_dialog_parent_class = NULL;
static gint AlmCalendarWidget_private_offset;
static gpointer alm_calendar_widget_parent_class = NULL;

VALA_EXTERN GType alm_calendar_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AlmCalendarDialog, g_object_unref)
VALA_EXTERN AlmCalendarDialog* alm_calendar_dialog_new (void);
VALA_EXTERN AlmCalendarDialog* alm_calendar_dialog_construct (GType object_type);
VALA_EXTERN GtkCalendar* alm_calendar_dialog_get_calendar_widget (AlmCalendarDialog* self);
static void alm_calendar_dialog_finalize (GObject * obj);
static GType alm_calendar_dialog_get_type_once (void);
VALA_EXTERN GType alm_calendar_widget_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AlmCalendarWidget, g_object_unref)
VALA_EXTERN AlmCalendarWidget* alm_calendar_widget_new (GtkButton* button);
VALA_EXTERN 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 __lambda8_ (Block2Data* _data2_);
VALA_EXTERN void alm_calendar_widget_on_clicked (AlmCalendarWidget* self,
                                     GtkWidget* widget,
                                     GtkEntry* entry,
                                     AlmCalendarDialog* dialog);
static void ___lambda8__gtk_button_clicked (GtkButton* _sender,
                                     gpointer self);
static void __lambda11_ (Block2Data* _data2_);
static void ___lambda11__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
VALA_EXTERN void alm_calendar_widget_set_up_calendar (AlmCalendarWidget* self,
                                          GtkButton* widget,
                                          GtkEntry* entry,
                                          AlmCalendarDialog* dialog);
VALA_EXTERN ZeitgeistTimeRange* alm_calendar_widget_get_range (AlmCalendarWidget* self);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static gboolean __lambda9_ (Block3Data* _data3_,
                     GtkWidget* w,
                     GdkEventFocus* e);
static gboolean ___lambda9__gtk_widget_focus_out_event (GtkWidget* _sender,
                                                 GdkEventFocus* event,
                                                 gpointer self);
static void __lambda10_ (Block3Data* _data3_);
static void ___lambda10__gtk_calendar_day_selected_double_click (GtkCalendar* _sender,
                                                          gpointer self);
static void alm_calendar_widget_finalize (GObject * obj);
static GType alm_calendar_widget_get_type_once (void);

static inline gpointer
alm_calendar_dialog_get_instance_private (AlmCalendarDialog* self)
{
	return G_STRUCT_MEMBER_P (self, AlmCalendarDialog_private_offset);
}

AlmCalendarDialog*
alm_calendar_dialog_construct (GType object_type)
{
	AlmCalendarDialog * self = NULL;
	GtkCalendar* _tmp0_;
	GtkBox* _tmp1_;
	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_container_get_type (), 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* _tmp0_;
	GtkCalendar* _tmp1_;
	GtkCalendar* result;
	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,
                                gpointer klass_data)
{
	alm_calendar_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AlmCalendarDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = alm_calendar_dialog_finalize;
}

static void
alm_calendar_dialog_instance_init (AlmCalendarDialog * self,
                                   gpointer klass)
{
	self->priv = alm_calendar_dialog_get_instance_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);
}

static GType
alm_calendar_dialog_get_type_once (void)
{
	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_dialog_get_type (), "AlmCalendarDialog", &g_define_type_info, 0);
	AlmCalendarDialog_private_offset = g_type_add_instance_private (alm_calendar_dialog_type_id, sizeof (AlmCalendarDialogPrivate));
	return alm_calendar_dialog_type_id;
}

GType
alm_calendar_dialog_get_type (void)
{
	static volatile gsize alm_calendar_dialog_type_id__once = 0;
	if (g_once_init_enter (&alm_calendar_dialog_type_id__once)) {
		GType alm_calendar_dialog_type_id;
		alm_calendar_dialog_type_id = alm_calendar_dialog_get_type_once ();
		g_once_init_leave (&alm_calendar_dialog_type_id__once, alm_calendar_dialog_type_id);
	}
	return alm_calendar_dialog_type_id__once;
}

static inline gpointer
alm_calendar_widget_get_instance_private (AlmCalendarWidget* self)
{
	return G_STRUCT_MEMBER_P (self, AlmCalendarWidget_private_offset);
}

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
__lambda8_ (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
___lambda8__gtk_button_clicked (GtkButton* _sender,
                                gpointer self)
{
	__lambda8_ (self);
}

static void
__lambda11_ (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
___lambda11__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda11_ (self);
}

AlmCalendarWidget*
alm_calendar_widget_construct (GType object_type,
                               GtkButton* button)
{
	AlmCalendarWidget * self = NULL;
	Block2Data* _data2_;
	GtkButton* _tmp0_;
	AlmCalendarDialog* _tmp1_;
	AlmCalendarDialog* _tmp2_;
	GtkBox* box1 = NULL;
	GtkBox* _tmp3_;
	GtkEntry* _tmp4_;
	GtkButton* _tmp5_;
	GtkArrow* arrow1 = NULL;
	GtkArrow* _tmp6_;
	GtkEntry* _tmp7_;
	GtkEntry* _tmp8_;
	GtkEntry* _tmp9_;
	GtkBox* box2 = NULL;
	GtkBox* _tmp10_;
	GtkEntry* _tmp11_;
	GtkButton* _tmp12_;
	GtkArrow* arrow2 = NULL;
	GtkArrow* _tmp13_;
	GtkEntry* _tmp14_;
	GtkEntry* _tmp15_;
	GtkEntry* _tmp16_;
	GtkLabel* start_label = NULL;
	GtkLabel* _tmp17_;
	GtkLabel* end_label = NULL;
	GtkLabel* _tmp18_;
	GtkLabel* _tmp19_;
	GtkLabel* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	GtkEntry* _tmp23_;
	AlmCalendarDialog* _tmp24_;
	GtkEntry* _tmp25_;
	AlmCalendarDialog* _tmp26_;
	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_ = _g_object_ref0 (button);
	_g_object_unref0 (self->priv->button);
	self->priv->button = _tmp0_;
	_tmp1_ = alm_calendar_dialog_new ();
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->start_dialog);
	self->priv->start_dialog = _tmp1_;
	_tmp2_ = alm_calendar_dialog_new ();
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->end_dialog);
	self->priv->end_dialog = _tmp2_;
	gtk_grid_set_row_spacing ((GtkGrid*) self, (guint) 10);
	gtk_grid_set_column_spacing ((GtkGrid*) self, (guint) 15);
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp3_);
	box1 = _tmp3_;
	_tmp4_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->start_entry);
	self->priv->start_entry = _tmp4_;
	_tmp5_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp5_);
	_data2_->start_button = _tmp5_;
	_tmp6_ = (GtkArrow*) gtk_arrow_new (GTK_ARROW_DOWN, 0);
	g_object_ref_sink (_tmp6_);
	arrow1 = _tmp6_;
	gtk_container_add ((GtkContainer*) _data2_->start_button, (GtkWidget*) arrow1);
	_tmp7_ = self->priv->start_entry;
	gtk_editable_set_editable ((GtkEditable*) _tmp7_, FALSE);
	_tmp8_ = self->priv->start_entry;
	gtk_widget_set_size_request ((GtkWidget*) _tmp8_, 100, -1);
	_tmp9_ = self->priv->start_entry;
	gtk_box_pack_start (box1, (GtkWidget*) _tmp9_, 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) ___lambda8__gtk_button_clicked, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp10_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp10_);
	box2 = _tmp10_;
	_tmp11_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp11_);
	_g_object_unref0 (self->priv->end_entry);
	self->priv->end_entry = _tmp11_;
	_tmp12_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp12_);
	_data2_->end_button = _tmp12_;
	_tmp13_ = (GtkArrow*) gtk_arrow_new (GTK_ARROW_DOWN, 0);
	g_object_ref_sink (_tmp13_);
	arrow2 = _tmp13_;
	gtk_container_add ((GtkContainer*) _data2_->end_button, (GtkWidget*) arrow2);
	_tmp14_ = self->priv->end_entry;
	gtk_editable_set_editable ((GtkEditable*) _tmp14_, FALSE);
	_tmp15_ = self->priv->end_entry;
	gtk_widget_set_size_request ((GtkWidget*) _tmp15_, 100, -1);
	_tmp16_ = self->priv->end_entry;
	gtk_box_pack_start (box2, (GtkWidget*) _tmp16_, 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) ___lambda11__gtk_button_clicked, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp17_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp17_);
	start_label = _tmp17_;
	gtk_label_set_markup (start_label, _ ("From:"));
	gtk_misc_set_alignment ((GtkMisc*) start_label, (gfloat) 1, (gfloat) (0 / 5));
	_tmp18_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp18_);
	end_label = _tmp18_;
	gtk_label_set_markup (end_label, _ ("To:"));
	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);
	_tmp19_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->invalid_label);
	self->priv->invalid_label = _tmp19_;
	_tmp20_ = self->priv->invalid_label;
	_tmp21_ = g_strdup_printf ("<span color='red'><b>%s</b></span>", _ ("Invalid Timerange"));
	_tmp22_ = _tmp21_;
	gtk_label_set_markup (_tmp20_, _tmp22_);
	_g_free0 (_tmp22_);
	_tmp23_ = self->priv->start_entry;
	_tmp24_ = self->priv->start_dialog;
	alm_calendar_widget_set_up_calendar (self, _data2_->start_button, _tmp23_, _tmp24_);
	_tmp25_ = self->priv->end_entry;
	_tmp26_ = self->priv->end_dialog;
	alm_calendar_widget_set_up_calendar (self, _data2_->end_button, _tmp25_, _tmp26_);
	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)
{
	GtkCalendar* calendar = NULL;
	AlmCalendarDialog* _tmp0_;
	GtkCalendar* _tmp1_;
	guint year = 0U;
	guint month = 0U;
	guint day = 0U;
	GtkCalendar* _tmp2_;
	guint _tmp3_ = 0U;
	guint _tmp4_ = 0U;
	guint _tmp5_ = 0U;
	GDateTime* date = NULL;
	GDateTime* _tmp6_;
	gint64 start = 0LL;
	GDateTime* _tmp7_;
	AlmCalendarDialog* _tmp8_;
	GtkCalendar* _tmp9_;
	GtkCalendar* _tmp10_;
	guint _tmp11_ = 0U;
	guint _tmp12_ = 0U;
	guint _tmp13_ = 0U;
	GDateTime* _tmp14_;
	gint64 end = 0LL;
	GDateTime* _tmp15_;
	ZeitgeistTimeRange* _tmp23_;
	ZeitgeistTimeRange* result;
	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_ = g_date_time_new_local ((gint) year, ((gint) month) + 1, (gint) day, 0, 0, (gdouble) 0);
	date = _tmp6_;
	_tmp7_ = date;
	start = g_date_time_to_unix (_tmp7_) * 1000;
	_tmp8_ = self->priv->end_dialog;
	_tmp9_ = alm_calendar_dialog_get_calendar_widget (_tmp8_);
	_g_object_unref0 (calendar);
	calendar = _tmp9_;
	_tmp10_ = calendar;
	gtk_calendar_get_date (_tmp10_, &_tmp11_, &_tmp12_, &_tmp13_);
	year = _tmp11_;
	month = _tmp12_;
	day = _tmp13_;
	_tmp14_ = g_date_time_new_local ((gint) year, ((gint) month) + 1, (gint) day, 0, 0, (gdouble) 0);
	_g_date_time_unref0 (date);
	date = _tmp14_;
	_tmp15_ = date;
	end = g_date_time_to_unix (_tmp15_) * 1000;
	if (start > end) {
		GtkButton* _tmp16_;
		GtkLabel* _tmp17_;
		GtkContainer* _tmp18_;
		GtkLabel* _tmp20_;
		_tmp16_ = self->priv->button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp16_, FALSE);
		_tmp17_ = self->priv->invalid_label;
		_tmp18_ = gtk_widget_get_parent ((GtkWidget*) _tmp17_);
		if (_tmp18_ == NULL) {
			GtkLabel* _tmp19_;
			_tmp19_ = self->priv->invalid_label;
			gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp19_, 2, 0, 1, 2);
		}
		_tmp20_ = self->priv->invalid_label;
		gtk_widget_show ((GtkWidget*) _tmp20_);
	} else {
		GtkButton* _tmp21_;
		GtkLabel* _tmp22_;
		_tmp21_ = self->priv->button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp21_, TRUE);
		_tmp22_ = self->priv->invalid_label;
		gtk_widget_hide ((GtkWidget*) _tmp22_);
	}
	_tmp23_ = zeitgeist_time_range_new (start, end);
	result = _tmp23_;
	_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)
{
	GtkCalendar* calendar = NULL;
	GtkCalendar* _tmp0_;
	guint year = 0U;
	guint month = 0U;
	guint day = 0U;
	guint _tmp1_ = 0U;
	guint _tmp2_ = 0U;
	guint _tmp3_ = 0U;
	GDateTime* date = NULL;
	GDateTime* _tmp4_;
	gchar* date_string = NULL;
	gchar* _tmp5_;
	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_ = alm_calendar_dialog_get_calendar_widget (dialog);
	calendar = _tmp0_;
	gtk_calendar_get_date (calendar, &_tmp1_, &_tmp2_, &_tmp3_);
	year = _tmp1_;
	month = _tmp2_;
	day = _tmp3_;
	_tmp4_ = g_date_time_new_local ((gint) year, ((gint) month) + 1, (gint) day, 0, 0, (gdouble) 0);
	date = _tmp4_;
	_tmp5_ = g_date_time_format (date, _ ("%d %B %Y"));
	date_string = _tmp5_;
	gtk_entry_set_text (entry, date_string);
	gtk_widget_set_sensitive ((GtkWidget*) widget, TRUE);
	gtk_widget_hide ((GtkWidget*) dialog);
	_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
__lambda9_ (Block3Data* _data3_,
            GtkWidget* w,
            GdkEventFocus* e)
{
	AlmCalendarWidget* self;
	gboolean result;
	self = _data3_->self;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	gtk_widget_hide ((GtkWidget*) _data3_->dialog);
	gtk_widget_set_sensitive (_data3_->widget, TRUE);
	result = FALSE;
	return result;
}

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

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

static void
___lambda10__gtk_calendar_day_selected_double_click (GtkCalendar* _sender,
                                                     gpointer self)
{
	__lambda10_ (self);
}

void
alm_calendar_widget_on_clicked (AlmCalendarWidget* self,
                                GtkWidget* widget,
                                GtkEntry* entry,
                                AlmCalendarDialog* dialog)
{
	Block3Data* _data3_;
	GtkWidget* _tmp0_;
	GtkEntry* _tmp1_;
	AlmCalendarDialog* _tmp2_;
	GdkWindow* parent_window = NULL;
	GdkWindow* _tmp3_;
	GdkWindow* _tmp4_;
	gint window_x = 0;
	gint window_y = 0;
	gint _tmp5_ = 0;
	gint _tmp6_ = 0;
	GtkAllocation allocation = {0};
	GtkAllocation _tmp7_ = {0};
	GtkAllocation _tmp8_;
	GtkAllocation _tmp9_;
	GtkAllocation _tmp10_;
	GtkAllocation _tmp11_;
	GtkCalendar* cal = NULL;
	GtkCalendar* _tmp12_;
	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_ = _g_object_ref0 (widget);
	_g_object_unref0 (_data3_->widget);
	_data3_->widget = _tmp0_;
	_tmp1_ = _g_object_ref0 (entry);
	_g_object_unref0 (_data3_->entry);
	_data3_->entry = _tmp1_;
	_tmp2_ = _g_object_ref0 (dialog);
	_g_object_unref0 (_data3_->dialog);
	_data3_->dialog = _tmp2_;
	gtk_widget_show_all ((GtkWidget*) _data3_->dialog);
	_tmp3_ = gtk_widget_get_parent_window ((GtkWidget*) self);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	parent_window = _tmp4_;
	gdk_window_get_position (parent_window, &_tmp5_, &_tmp6_);
	window_x = _tmp5_;
	window_y = _tmp6_;
	gtk_widget_get_allocation ((GtkWidget*) _data3_->entry, &_tmp7_);
	allocation = _tmp7_;
	_tmp8_ = allocation;
	_tmp9_ = allocation;
	_tmp10_ = allocation;
	gtk_window_move ((GtkWindow*) _data3_->dialog, window_x + _tmp8_.x, (window_y + _tmp9_.y) + _tmp10_.height);
	_tmp11_ = allocation;
	gtk_widget_set_size_request ((GtkWidget*) _data3_->dialog, _tmp11_.width, -1);
	gtk_window_set_resizable ((GtkWindow*) _data3_->dialog, FALSE);
	gtk_widget_set_sensitive (_data3_->widget, FALSE);
	g_signal_connect_data ((GtkWidget*) _data3_->dialog, "focus-out-event", (GCallback) ___lambda9__gtk_widget_focus_out_event, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, G_CONNECT_AFTER);
	_tmp12_ = alm_calendar_dialog_get_calendar_widget (_data3_->dialog);
	cal = _tmp12_;
	g_signal_connect_data (cal, "day-selected-double-click", (GCallback) ___lambda10__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,
                                gpointer klass_data)
{
	alm_calendar_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &AlmCalendarWidget_private_offset);
	G_OBJECT_CLASS (klass)->finalize = alm_calendar_widget_finalize;
}

static void
alm_calendar_widget_instance_init (AlmCalendarWidget * self,
                                   gpointer klass)
{
	self->priv = alm_calendar_widget_get_instance_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);
}

static GType
alm_calendar_widget_get_type_once (void)
{
	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_grid_get_type (), "AlmCalendarWidget", &g_define_type_info, 0);
	AlmCalendarWidget_private_offset = g_type_add_instance_private (alm_calendar_widget_type_id, sizeof (AlmCalendarWidgetPrivate));
	return alm_calendar_widget_type_id;
}

GType
alm_calendar_widget_get_type (void)
{
	static volatile gsize alm_calendar_widget_type_id__once = 0;
	if (g_once_init_enter (&alm_calendar_widget_type_id__once)) {
		GType alm_calendar_widget_type_id;
		alm_calendar_widget_type_id = alm_calendar_widget_get_type_once ();
		g_once_init_leave (&alm_calendar_widget_type_id__once, alm_calendar_widget_type_id);
	}
	return alm_calendar_widget_type_id__once;
}

