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

/*-
 * Copyright (c) 2011-2026 elementary, Inc. (https://elementary.io)
 *
 * 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 3 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/>.
 *
 * Authored by: Maxwell Barvian
 *              Corentin Noël <corentin@elementaryos.org>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.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 MAYA_VIEW_TYPE_WEEK_LABELS (maya_view_week_labels_get_type ())
#define MAYA_VIEW_WEEK_LABELS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYA_VIEW_TYPE_WEEK_LABELS, MayaViewWeekLabels))
#define MAYA_VIEW_WEEK_LABELS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAYA_VIEW_TYPE_WEEK_LABELS, MayaViewWeekLabelsClass))
#define MAYA_VIEW_IS_WEEK_LABELS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYA_VIEW_TYPE_WEEK_LABELS))
#define MAYA_VIEW_IS_WEEK_LABELS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAYA_VIEW_TYPE_WEEK_LABELS))
#define MAYA_VIEW_WEEK_LABELS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAYA_VIEW_TYPE_WEEK_LABELS, MayaViewWeekLabelsClass))

typedef struct _MayaViewWeekLabels MayaViewWeekLabels;
typedef struct _MayaViewWeekLabelsClass MayaViewWeekLabelsClass;
typedef struct _MayaViewWeekLabelsPrivate MayaViewWeekLabelsPrivate;
enum  {
	MAYA_VIEW_WEEK_LABELS_0_PROPERTY,
	MAYA_VIEW_WEEK_LABELS_NUM_PROPERTIES
};
static GParamSpec* maya_view_week_labels_properties[MAYA_VIEW_WEEK_LABELS_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block24Data Block24Data;
#define __vala_GdkEvent_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEvent_free (var), NULL)))
#define __vala_GdkEventSequence_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEventSequence_free (var), NULL)))

struct _MayaViewWeekLabels {
	GtkBin parent_instance;
	MayaViewWeekLabelsPrivate * priv;
};

struct _MayaViewWeekLabelsClass {
	GtkBinClass parent_class;
};

struct _MayaViewWeekLabelsPrivate {
	GtkGrid* day_grid;
	GtkLabel** labels;
	gint labels_length1;
	gint _labels_size_;
	gint nr_of_weeks;
	GtkGestureMultiPress* click_gesture;
	GtkGestureLongPress* long_press_gesture;
};

struct _Block24Data {
	int _ref_count_;
	MayaViewWeekLabels* self;
	GtkMenu* gtk_menu;
};

static gint MayaViewWeekLabels_private_offset;
static gpointer maya_view_week_labels_parent_class = NULL;
static GSettings* maya_view_week_labels_show_weeks;
static GSettings* maya_view_week_labels_show_weeks = NULL;
VALA_EXTERN GSettings* maya_application_wingpanel_settings;
VALA_EXTERN GSettings* maya_application_saved_state;

VALA_EXTERN GType maya_view_week_labels_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MayaViewWeekLabels, g_object_unref)
VALA_EXTERN void maya_view_week_labels_update (MayaViewWeekLabels* self,
                                   GDateTime* date,
                                   gint nr_of_weeks);
VALA_EXTERN void maya_view_week_labels_set_nr_of_weeks (MayaViewWeekLabels* self,
                                            gint new_number);
VALA_EXTERN gint maya_view_week_labels_get_nr_of_weeks (MayaViewWeekLabels* self);
VALA_EXTERN MayaViewWeekLabels* maya_view_week_labels_new (void);
VALA_EXTERN MayaViewWeekLabels* maya_view_week_labels_construct (GType object_type);
static GObject * maya_view_week_labels_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static Block24Data* block24_data_ref (Block24Data* _data24_);
static void block24_data_unref (void * _userdata_);
static void _maya_view_week_labels___lambda127_ (Block24Data* _data24_,
                                          gint n_press,
                                          gdouble x,
                                          gdouble y);
static GdkEvent* _vala_GdkEvent_copy (GdkEvent* self);
static void _vala_GdkEvent_free (GdkEvent* self);
static void _vala_GdkEventSequence_free (GdkEventSequence* self);
static void __maya_view_week_labels___lambda127__gtk_gesture_multi_press_pressed (GtkGestureMultiPress* _sender,
                                                                           gint n_press,
                                                                           gdouble x,
                                                                           gdouble y,
                                                                           gpointer self);
static void _maya_view_week_labels___lambda128_ (Block24Data* _data24_,
                                          gdouble x,
                                          gdouble y);
static void __maya_view_week_labels___lambda128__gtk_gesture_long_press_pressed (GtkGestureLongPress* _sender,
                                                                          gdouble x,
                                                                          gdouble y,
                                                                          gpointer self);
static void maya_view_week_labels_finalize (GObject * obj);
static GType maya_view_week_labels_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
maya_view_week_labels_get_instance_private (MayaViewWeekLabels* self)
{
	return G_STRUCT_MEMBER_P (self, MayaViewWeekLabels_private_offset);
}

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

static gpointer
_g_date_time_ref0 (gpointer self)
{
	return self ? g_date_time_ref (self) : NULL;
}

void
maya_view_week_labels_update (MayaViewWeekLabels* self,
                              GDateTime* date,
                              gint nr_of_weeks)
{
	GSettings* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (date != NULL);
	_tmp0_ = maya_view_week_labels_show_weeks;
	if (g_settings_get_boolean (_tmp0_, "show-weeks")) {
		GtkLabel** _tmp1_;
		gint _tmp1__length1;
		GtkLabel** _tmp5_;
		GDateTime* next = NULL;
		GDateTime* _tmp18_;
		gint days_to_add = 0;
		GDateTime* _tmp19_;
		GDateTime* _tmp20_;
		GDateTime* _tmp21_;
		GtkLabel** _tmp22_;
		gint _tmp22__length1;
		_tmp1_ = self->priv->labels;
		_tmp1__length1 = self->priv->labels_length1;
		if (_tmp1_ != NULL) {
			GtkLabel** _tmp2_;
			gint _tmp2__length1;
			_tmp2_ = self->priv->labels;
			_tmp2__length1 = self->priv->labels_length1;
			{
				GtkLabel** label_collection = NULL;
				gint label_collection_length1 = 0;
				gint _label_collection_size_ = 0;
				gint label_it = 0;
				label_collection = _tmp2_;
				label_collection_length1 = _tmp2__length1;
				for (label_it = 0; label_it < label_collection_length1; label_it = label_it + 1) {
					GtkLabel* _tmp3_;
					GtkLabel* label = NULL;
					_tmp3_ = _g_object_ref0 (label_collection[label_it]);
					label = _tmp3_;
					{
						GtkLabel* _tmp4_;
						_tmp4_ = label;
						gtk_widget_destroy ((GtkWidget*) _tmp4_);
						_g_object_unref0 (label);
					}
				}
			}
		}
		_tmp5_ = g_new0 (GtkLabel*, nr_of_weeks + 1);
		self->priv->labels = (_vala_array_free (self->priv->labels, self->priv->labels_length1, (GDestroyNotify) g_object_unref), NULL);
		self->priv->labels = _tmp5_;
		self->priv->labels_length1 = nr_of_weeks;
		self->priv->_labels_size_ = self->priv->labels_length1;
		{
			gint c = 0;
			c = 0;
			{
				gboolean _tmp6_ = FALSE;
				_tmp6_ = TRUE;
				while (TRUE) {
					GtkLabel** _tmp8_;
					gint _tmp8__length1;
					GtkLabel* _tmp9_ = NULL;
					GtkLabel** _tmp10_;
					gint _tmp10__length1;
					GtkLabel* _tmp11_;
					GtkStyleContext* _tmp12_;
					GtkGrid* _tmp13_;
					GtkLabel** _tmp14_;
					gint _tmp14__length1;
					GtkLabel* _tmp15_;
					GtkLabel** _tmp16_;
					gint _tmp16__length1;
					GtkLabel* _tmp17_;
					if (!_tmp6_) {
						gint _tmp7_;
						_tmp7_ = c;
						c = _tmp7_ + 1;
					}
					_tmp6_ = FALSE;
					if (!(c < nr_of_weeks)) {
						break;
					}
					_tmp8_ = self->priv->labels;
					_tmp8__length1 = self->priv->labels_length1;
					_tmp9_ = (GtkLabel*) gtk_label_new ("");
					gtk_widget_set_valign ((GtkWidget*) _tmp9_, GTK_ALIGN_START);
					gtk_label_set_width_chars (_tmp9_, 2);
					g_object_ref_sink (_tmp9_);
					_g_object_unref0 (_tmp8_[c]);
					_tmp8_[c] = _tmp9_;
					_tmp10_ = self->priv->labels;
					_tmp10__length1 = self->priv->labels_length1;
					_tmp11_ = _tmp10_[c];
					_tmp12_ = gtk_widget_get_style_context ((GtkWidget*) _tmp11_);
					gtk_style_context_add_class (_tmp12_, "weeklabel");
					_tmp13_ = self->priv->day_grid;
					_tmp14_ = self->priv->labels;
					_tmp14__length1 = self->priv->labels_length1;
					_tmp15_ = _tmp14_[c];
					gtk_grid_attach (_tmp13_, (GtkWidget*) _tmp15_, 0, c, 1, 1);
					_tmp16_ = self->priv->labels;
					_tmp16__length1 = self->priv->labels_length1;
					_tmp17_ = _tmp16_[c];
					gtk_widget_show ((GtkWidget*) _tmp17_);
				}
			}
		}
		_tmp18_ = _g_date_time_ref0 (date);
		next = _tmp18_;
		_tmp19_ = next;
		days_to_add = (8 - g_date_time_get_day_of_week (_tmp19_)) % 7;
		_tmp20_ = next;
		_tmp21_ = g_date_time_add_days (_tmp20_, days_to_add);
		_g_date_time_unref0 (next);
		next = _tmp21_;
		_tmp22_ = self->priv->labels;
		_tmp22__length1 = self->priv->labels_length1;
		{
			GtkLabel** label_collection = NULL;
			gint label_collection_length1 = 0;
			gint _label_collection_size_ = 0;
			gint label_it = 0;
			label_collection = _tmp22_;
			label_collection_length1 = _tmp22__length1;
			for (label_it = 0; label_it < label_collection_length1; label_it = label_it + 1) {
				GtkLabel* _tmp23_;
				GtkLabel* label = NULL;
				_tmp23_ = _g_object_ref0 (label_collection[label_it]);
				label = _tmp23_;
				{
					GtkLabel* _tmp24_;
					GDateTime* _tmp25_;
					gchar* _tmp26_;
					gchar* _tmp27_;
					GDateTime* _tmp28_;
					GDateTime* _tmp29_;
					_tmp24_ = label;
					_tmp25_ = next;
					_tmp26_ = g_strdup_printf ("%i", g_date_time_get_week_of_year (_tmp25_));
					_tmp27_ = _tmp26_;
					gtk_label_set_label (_tmp24_, _tmp27_);
					_g_free0 (_tmp27_);
					_tmp28_ = next;
					_tmp29_ = g_date_time_add_weeks (_tmp28_, 1);
					_g_date_time_unref0 (next);
					next = _tmp29_;
					_g_object_unref0 (label);
				}
			}
		}
		_g_date_time_unref0 (next);
	}
}

void
maya_view_week_labels_set_nr_of_weeks (MayaViewWeekLabels* self,
                                       gint new_number)
{
	GtkGrid* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->day_grid;
	gtk_grid_insert_row (_tmp0_, new_number);
	self->priv->nr_of_weeks = new_number;
}

gint
maya_view_week_labels_get_nr_of_weeks (MayaViewWeekLabels* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->nr_of_weeks;
	return result;
}

MayaViewWeekLabels*
maya_view_week_labels_construct (GType object_type)
{
	MayaViewWeekLabels * self = NULL;
	self = (MayaViewWeekLabels*) g_object_new (object_type, NULL);
	return self;
}

MayaViewWeekLabels*
maya_view_week_labels_new (void)
{
	return maya_view_week_labels_construct (MAYA_VIEW_TYPE_WEEK_LABELS);
}

static Block24Data*
block24_data_ref (Block24Data* _data24_)
{
	g_atomic_int_inc (&_data24_->_ref_count_);
	return _data24_;
}

static void
block24_data_unref (void * _userdata_)
{
	Block24Data* _data24_;
	_data24_ = (Block24Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data24_->_ref_count_)) {
		MayaViewWeekLabels* self;
		self = _data24_->self;
		_g_object_unref0 (_data24_->gtk_menu);
		_g_object_unref0 (self);
		g_slice_free (Block24Data, _data24_);
	}
}

static GdkEvent*
_vala_GdkEvent_copy (GdkEvent* self)
{
	return g_boxed_copy (gdk_event_get_type (), self);
}

static gpointer
__vala_GdkEvent_copy0 (gpointer self)
{
	return self ? _vala_GdkEvent_copy (self) : NULL;
}

static void
_vala_GdkEvent_free (GdkEvent* self)
{
	g_boxed_free (gdk_event_get_type (), self);
}

static void
_vala_GdkEventSequence_free (GdkEventSequence* self)
{
	g_boxed_free (gdk_event_sequence_get_type (), self);
}

static void
_maya_view_week_labels___lambda127_ (Block24Data* _data24_,
                                     gint n_press,
                                     gdouble x,
                                     gdouble y)
{
	MayaViewWeekLabels* self;
	GdkEventSequence* sequence = NULL;
	GtkGestureMultiPress* _tmp0_;
	GdkEventSequence* _tmp1_;
	GdkEvent* event = NULL;
	GtkGestureMultiPress* _tmp2_;
	GdkEventSequence* _tmp3_;
	GdkEvent* _tmp4_;
	GdkEvent* _tmp5_;
	GdkEvent* _tmp6_;
	self = _data24_->self;
	_tmp0_ = self->priv->click_gesture;
	_tmp1_ = gtk_gesture_single_get_current_sequence ((GtkGestureSingle*) _tmp0_);
	sequence = _tmp1_;
	_tmp2_ = self->priv->click_gesture;
	_tmp3_ = sequence;
	_tmp4_ = gtk_gesture_get_last_event ((GtkGesture*) _tmp2_, _tmp3_);
	_tmp5_ = __vala_GdkEvent_copy0 (_tmp4_);
	event = _tmp5_;
	_tmp6_ = event;
	if (gdk_event_triggers_context_menu (_tmp6_)) {
		GtkMenu* _tmp7_;
		GdkEvent* _tmp8_;
		GtkGestureMultiPress* _tmp9_;
		GtkGestureMultiPress* _tmp10_;
		_tmp7_ = _data24_->gtk_menu;
		_tmp8_ = event;
		gtk_menu_popup_at_pointer (_tmp7_, _tmp8_);
		_tmp9_ = self->priv->click_gesture;
		gtk_gesture_set_state ((GtkGesture*) _tmp9_, GTK_EVENT_SEQUENCE_CLAIMED);
		_tmp10_ = self->priv->click_gesture;
		gtk_event_controller_reset ((GtkEventController*) _tmp10_);
	}
	__vala_GdkEvent_free0 (event);
	__vala_GdkEventSequence_free0 (sequence);
}

static void
__maya_view_week_labels___lambda127__gtk_gesture_multi_press_pressed (GtkGestureMultiPress* _sender,
                                                                      gint n_press,
                                                                      gdouble x,
                                                                      gdouble y,
                                                                      gpointer self)
{
	_maya_view_week_labels___lambda127_ (self, n_press, x, y);
}

static void
_maya_view_week_labels___lambda128_ (Block24Data* _data24_,
                                     gdouble x,
                                     gdouble y)
{
	MayaViewWeekLabels* self;
	GdkEventSequence* sequence = NULL;
	GtkGestureLongPress* _tmp0_;
	GdkEventSequence* _tmp1_;
	GdkEvent* event = NULL;
	GtkGestureLongPress* _tmp2_;
	GdkEventSequence* _tmp3_;
	GdkEvent* _tmp4_;
	GdkEvent* _tmp5_;
	GtkMenu* _tmp6_;
	GdkEvent* _tmp7_;
	GtkGestureLongPress* _tmp8_;
	GtkGestureLongPress* _tmp9_;
	self = _data24_->self;
	_tmp0_ = self->priv->long_press_gesture;
	_tmp1_ = gtk_gesture_single_get_current_sequence ((GtkGestureSingle*) _tmp0_);
	sequence = _tmp1_;
	_tmp2_ = self->priv->long_press_gesture;
	_tmp3_ = sequence;
	_tmp4_ = gtk_gesture_get_last_event ((GtkGesture*) _tmp2_, _tmp3_);
	_tmp5_ = __vala_GdkEvent_copy0 (_tmp4_);
	event = _tmp5_;
	_tmp6_ = _data24_->gtk_menu;
	_tmp7_ = event;
	gtk_menu_popup_at_pointer (_tmp6_, _tmp7_);
	_tmp8_ = self->priv->long_press_gesture;
	gtk_gesture_set_state ((GtkGesture*) _tmp8_, GTK_EVENT_SEQUENCE_CLAIMED);
	_tmp9_ = self->priv->long_press_gesture;
	gtk_event_controller_reset ((GtkEventController*) _tmp9_);
	__vala_GdkEvent_free0 (event);
	__vala_GdkEventSequence_free0 (sequence);
}

static void
__maya_view_week_labels___lambda128__gtk_gesture_long_press_pressed (GtkGestureLongPress* _sender,
                                                                     gdouble x,
                                                                     gdouble y,
                                                                     gpointer self)
{
	_maya_view_week_labels___lambda128_ (self, x, y);
}

static GObject *
maya_view_week_labels_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	MayaViewWeekLabels * self;
	Block24Data* _data24_;
	GtkGrid* _tmp0_ = NULL;
	GtkGrid* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkGrid* _tmp3_;
	GtkRevealer* revealer = NULL;
	GtkGrid* _tmp4_;
	GtkWidget* _tmp5_;
	GtkRevealer* _tmp6_ = NULL;
	GtkRevealer* _tmp7_;
	GSettings* _tmp8_;
	GtkRevealer* _tmp9_;
	GAction* action_show_weeks = NULL;
	GSettings* _tmp10_;
	GAction* _tmp11_;
	GSimpleActionGroup* action_group = NULL;
	GSimpleActionGroup* _tmp12_;
	GSimpleActionGroup* _tmp13_;
	GAction* _tmp14_;
	GSimpleActionGroup* _tmp15_;
	GMenu* menu = NULL;
	GMenu* _tmp16_;
	GMenu* _tmp17_;
	GMenu* _tmp18_;
	GtkWidget* _tmp19_;
	GtkMenu* _tmp20_ = NULL;
	GtkRevealer* _tmp21_;
	GtkGestureMultiPress* _tmp22_ = NULL;
	GtkGestureMultiPress* _tmp23_;
	GtkGestureLongPress* _tmp24_ = NULL;
	GtkGestureLongPress* _tmp25_;
	parent_class = G_OBJECT_CLASS (maya_view_week_labels_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAYA_VIEW_TYPE_WEEK_LABELS, MayaViewWeekLabels);
	_data24_ = g_slice_new0 (Block24Data);
	_data24_->_ref_count_ = 1;
	_data24_->self = g_object_ref (self);
	_tmp0_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_row_homogeneous (_tmp0_, TRUE);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->day_grid);
	self->priv->day_grid = _tmp0_;
	_tmp1_ = self->priv->day_grid;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_add_class (_tmp2_, "weeks");
	maya_view_week_labels_set_nr_of_weeks (self, 5);
	_tmp3_ = self->priv->day_grid;
	gtk_grid_insert_row (_tmp3_, 1);
	_tmp4_ = self->priv->day_grid;
	_tmp5_ = _g_object_ref0 ((GtkWidget*) _tmp4_);
	_tmp6_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_set ((GtkContainer*) _tmp6_, "child", _tmp5_, NULL);
	_g_object_unref0 (_tmp5_);
	gtk_revealer_set_transition_type (_tmp6_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
	g_object_ref_sink (_tmp6_);
	revealer = _tmp6_;
	_tmp7_ = revealer;
	g_object_set ((GtkContainer*) self, "child", (GtkWidget*) _tmp7_, NULL);
	gtk_widget_set_vexpand ((GtkWidget*) self, TRUE);
	_tmp8_ = maya_view_week_labels_show_weeks;
	_tmp9_ = revealer;
	g_settings_bind (_tmp8_, "show-weeks", (GObject*) _tmp9_, "reveal-child", G_SETTINGS_BIND_DEFAULT);
	_tmp10_ = maya_view_week_labels_show_weeks;
	_tmp11_ = g_settings_create_action (_tmp10_, "show-weeks");
	action_show_weeks = _tmp11_;
	_tmp12_ = g_simple_action_group_new ();
	action_group = _tmp12_;
	_tmp13_ = action_group;
	_tmp14_ = action_show_weeks;
	g_action_map_add_action ((GActionMap*) _tmp13_, _tmp14_);
	_tmp15_ = action_group;
	gtk_widget_insert_action_group ((GtkWidget*) self, "week-labels", (GActionGroup*) _tmp15_);
	_tmp16_ = g_menu_new ();
	menu = _tmp16_;
	_tmp17_ = menu;
	g_menu_append (_tmp17_, _ ("Show Week Numbers"), "week-labels.show-weeks");
	_tmp18_ = menu;
	_tmp19_ = _g_object_ref0 ((GtkWidget*) self);
	_tmp20_ = (GtkMenu*) gtk_menu_new_from_model ((GMenuModel*) _tmp18_);
	g_object_set (_tmp20_, "attach-widget", _tmp19_, NULL);
	_g_object_unref0 (_tmp19_);
	g_object_ref_sink (_tmp20_);
	_data24_->gtk_menu = _tmp20_;
	_tmp21_ = revealer;
	_tmp22_ = (GtkGestureMultiPress*) gtk_gesture_multi_press_new ((GtkWidget*) _tmp21_);
	gtk_gesture_single_set_button ((GtkGestureSingle*) _tmp22_, (guint) 0);
	_g_object_unref0 (self->priv->click_gesture);
	self->priv->click_gesture = _tmp22_;
	_tmp23_ = self->priv->click_gesture;
	g_signal_connect_data (_tmp23_, "pressed", (GCallback) __maya_view_week_labels___lambda127__gtk_gesture_multi_press_pressed, block24_data_ref (_data24_), (GClosureNotify) block24_data_unref, 0);
	_tmp24_ = (GtkGestureLongPress*) gtk_gesture_long_press_new ((GtkWidget*) self);
	gtk_gesture_single_set_touch_only ((GtkGestureSingle*) _tmp24_, TRUE);
	_g_object_unref0 (self->priv->long_press_gesture);
	self->priv->long_press_gesture = _tmp24_;
	_tmp25_ = self->priv->long_press_gesture;
	g_signal_connect_data (_tmp25_, "pressed", (GCallback) __maya_view_week_labels___lambda128__gtk_gesture_long_press_pressed, block24_data_ref (_data24_), (GClosureNotify) block24_data_unref, 0);
	_g_object_unref0 (menu);
	_g_object_unref0 (action_group);
	_g_object_unref0 (action_show_weeks);
	_g_object_unref0 (revealer);
	block24_data_unref (_data24_);
	_data24_ = NULL;
	return obj;
}

static void
maya_view_week_labels_class_init (MayaViewWeekLabelsClass * klass,
                                  gpointer klass_data)
{
	GSettings* _tmp0_;
	maya_view_week_labels_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MayaViewWeekLabels_private_offset);
	G_OBJECT_CLASS (klass)->constructor = maya_view_week_labels_constructor;
	G_OBJECT_CLASS (klass)->finalize = maya_view_week_labels_finalize;
	_tmp0_ = maya_application_wingpanel_settings;
	if (_tmp0_ != NULL) {
		GSettings* _tmp1_;
		GSettings* _tmp2_;
		_tmp1_ = maya_application_wingpanel_settings;
		_tmp2_ = _g_object_ref0 (_tmp1_);
		_g_object_unref0 (maya_view_week_labels_show_weeks);
		maya_view_week_labels_show_weeks = _tmp2_;
	} else {
		GSettings* _tmp3_;
		GSettings* _tmp4_;
		_tmp3_ = maya_application_saved_state;
		_tmp4_ = _g_object_ref0 (_tmp3_);
		_g_object_unref0 (maya_view_week_labels_show_weeks);
		maya_view_week_labels_show_weeks = _tmp4_;
	}
}

static void
maya_view_week_labels_instance_init (MayaViewWeekLabels * self,
                                     gpointer klass)
{
	self->priv = maya_view_week_labels_get_instance_private (self);
}

static void
maya_view_week_labels_finalize (GObject * obj)
{
	MayaViewWeekLabels * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAYA_VIEW_TYPE_WEEK_LABELS, MayaViewWeekLabels);
	_g_object_unref0 (self->priv->day_grid);
	self->priv->labels = (_vala_array_free (self->priv->labels, self->priv->labels_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (self->priv->click_gesture);
	_g_object_unref0 (self->priv->long_press_gesture);
	G_OBJECT_CLASS (maya_view_week_labels_parent_class)->finalize (obj);
}

/**
 * Represent the week labels at the left side of the grid.
 */
static GType
maya_view_week_labels_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MayaViewWeekLabelsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) maya_view_week_labels_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MayaViewWeekLabels), 0, (GInstanceInitFunc) maya_view_week_labels_instance_init, NULL };
	GType maya_view_week_labels_type_id;
	maya_view_week_labels_type_id = g_type_register_static (gtk_bin_get_type (), "MayaViewWeekLabels", &g_define_type_info, 0);
	MayaViewWeekLabels_private_offset = g_type_add_instance_private (maya_view_week_labels_type_id, sizeof (MayaViewWeekLabelsPrivate));
	return maya_view_week_labels_type_id;
}

GType
maya_view_week_labels_get_type (void)
{
	static volatile gsize maya_view_week_labels_type_id__once = 0;
	if (g_once_init_enter (&maya_view_week_labels_type_id__once)) {
		GType maya_view_week_labels_type_id;
		maya_view_week_labels_type_id = maya_view_week_labels_get_type_once ();
		g_once_init_leave (&maya_view_week_labels_type_id__once, maya_view_week_labels_type_id);
	}
	return maya_view_week_labels_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

