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

/*
* Copyright (c) 2009-2013 Yorba Foundation
*
* This program 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.1 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#include "io.elementary.photos.h"
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.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

enum  {
	EVENT_PAGE_0_PROPERTY,
	EVENT_PAGE_NUM_PROPERTIES
};
static GParamSpec* event_page_properties[EVENT_PAGE_NUM_PROPERTIES];
#define _data_collection_unref0(var) ((var == NULL) ? NULL : (var = (data_collection_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block13Data Block13Data;
enum  {
	NO_EVENT_PAGE_0_PROPERTY,
	NO_EVENT_PAGE_NUM_PROPERTIES
};
static GParamSpec* no_event_page_properties[NO_EVENT_PAGE_NUM_PROPERTIES];

#define NO_EVENT_PAGE_TYPE_NO_EVENT_VIEW_MANAGER (no_event_page_no_event_view_manager_get_type ())
#define NO_EVENT_PAGE_NO_EVENT_VIEW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NO_EVENT_PAGE_TYPE_NO_EVENT_VIEW_MANAGER, NoEventPageNoEventViewManager))
#define NO_EVENT_PAGE_NO_EVENT_VIEW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NO_EVENT_PAGE_TYPE_NO_EVENT_VIEW_MANAGER, NoEventPageNoEventViewManagerClass))
#define NO_EVENT_PAGE_IS_NO_EVENT_VIEW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NO_EVENT_PAGE_TYPE_NO_EVENT_VIEW_MANAGER))
#define NO_EVENT_PAGE_IS_NO_EVENT_VIEW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NO_EVENT_PAGE_TYPE_NO_EVENT_VIEW_MANAGER))
#define NO_EVENT_PAGE_NO_EVENT_VIEW_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NO_EVENT_PAGE_TYPE_NO_EVENT_VIEW_MANAGER, NoEventPageNoEventViewManagerClass))

typedef struct _NoEventPageNoEventViewManager NoEventPageNoEventViewManager;
typedef struct _NoEventPageNoEventViewManagerClass NoEventPageNoEventViewManagerClass;
#define _view_collection_monitor_unref0(var) ((var == NULL) ? NULL : (var = (view_collection_monitor_unref (var), NULL)))
#define _view_manager_unref0(var) ((var == NULL) ? NULL : (var = (view_manager_unref (var), NULL)))
typedef struct _NoEventPageNoEventViewManagerPrivate NoEventPageNoEventViewManagerPrivate;

struct _EventPagePrivate {
	Event* page_event;
	GtkMenu* page_sidebar_menu;
};

struct _Block13Data {
	int _ref_count_;
	EventPage* self;
	GtkAction* rename_action;
};

struct _NoEventPageNoEventViewManager {
	CollectionViewManager parent_instance;
	NoEventPageNoEventViewManagerPrivate * priv;
};

struct _NoEventPageNoEventViewManagerClass {
	CollectionViewManagerClass parent_class;
};

static gint EventPage_private_offset;
static gpointer event_page_parent_class = NULL;
static gpointer no_event_page_parent_class = NULL;
static Alteration* no_event_page_no_event_page_alteration;
static Alteration* no_event_page_no_event_page_alteration = NULL;
static gpointer no_event_page_no_event_view_manager_parent_class = NULL;

static void event_page_on_events_altered (EventPage* self,
                                   GeeMap* map);
static void _event_page_on_events_altered_data_collection_items_altered (DataCollection* _sender,
                                                                  GeeMap* items,
                                                                  gpointer self);
static DataView* _media_page_create_thumbnail_create_view (DataSource* source,
                                                    gpointer self);
static gboolean event_page_real_on_app_key_pressed (Page* base,
                                             GdkEventKey* event);
static GtkMenu* event_page_real_get_page_sidebar_menu (Page* base);
static Block13Data* block13_data_ref (Block13Data* _data13_);
static void block13_data_unref (void * _userdata_);
static void ___lambda55_ (Block13Data* _data13_);
static void ____lambda55__gtk_menu_item_activate (GtkMenuItem* _sender,
                                           gpointer self);
static GtkActionEntry* event_page_real_init_collect_action_entries (Page* base,
                                                             gint* result_length1);
static void event_page_on_make_primary (EventPage* self);
static void _event_page_on_make_primary_gcallback (GtkAction* action,
                                            gpointer self);
static void _vala_array_add148 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void event_page_on_rename (EventPage* self);
static void _event_page_on_rename_gcallback (GtkAction* action,
                                      gpointer self);
static void _vala_array_add149 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void event_page_real_init_actions (Page* base,
                                   gint selected_count,
                                   gint count);
static void event_page_real_update_actions (Page* base,
                                     gint selected_count,
                                     gint count);
static void event_page_real_get_config_photos_sort (MediaPage* base,
                                             gboolean* sort_order,
                                             gint* sort_by);
static void event_page_real_set_config_photos_sort (MediaPage* base,
                                             gboolean sort_order,
                                             gint sort_by);
static GtkBox* event_page_real_get_header_buttons (Page* base);
static void _event_page_back_to_master_clicked_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self);
static void event_page_finalize (GObject * obj);
static GType event_page_get_type_once (void);
static NoEventPageNoEventViewManager* no_event_page_no_event_view_manager_new (NoEventPage* page);
static NoEventPageNoEventViewManager* no_event_page_no_event_view_manager_construct (GType object_type,
                                                                              NoEventPage* page);
static GType no_event_page_no_event_view_manager_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void no_event_page_real_get_config_photos_sort (MediaPage* base,
                                                gboolean* sort_order,
                                                gint* sort_by);
static void no_event_page_real_set_config_photos_sort (MediaPage* base,
                                                gboolean sort_order,
                                                gint sort_by);
static gboolean no_event_page_no_event_view_manager_real_include_in_view (ViewManager* base,
                                                                   DataSource* source);
static GType no_event_page_no_event_view_manager_get_type_once (void);
static void no_event_page_finalize (GObject * obj);
static GType no_event_page_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
event_page_get_instance_private (EventPage* self)
{
	return G_STRUCT_MEMBER_P (self, EventPage_private_offset);
}

static void
_event_page_on_events_altered_data_collection_items_altered (DataCollection* _sender,
                                                             GeeMap* items,
                                                             gpointer self)
{
	event_page_on_events_altered ((EventPage*) self, items);
}

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

static DataView*
_media_page_create_thumbnail_create_view (DataSource* source,
                                          gpointer self)
{
	DataView* result;
	result = media_page_create_thumbnail ((MediaPage*) self, source);
	return result;
}

EventPage*
event_page_construct (GType object_type,
                      Event* page_event)
{
	EventPage * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	Event* _tmp2_;
	ViewCollection* _tmp3_;
	ViewCollection* _tmp4_;
	EventSourceCollection* _tmp5_;
	g_return_val_if_fail (page_event != NULL, NULL);
	_tmp0_ = data_object_get_name ((DataObject*) page_event);
	_tmp1_ = _tmp0_;
	self = (EventPage*) collection_page_construct (object_type, _tmp1_);
	_g_free0 (_tmp1_);
	_tmp2_ = _g_object_ref0 (page_event);
	_g_object_unref0 (self->priv->page_event);
	self->priv->page_event = _tmp2_;
	_tmp3_ = page_get_view ((Page*) self);
	_tmp4_ = _tmp3_;
	event_mirror_photos (page_event, _tmp4_, _media_page_create_thumbnail_create_view, (MediaPage*) self);
	_data_collection_unref0 (_tmp4_);
	_tmp5_ = event_global;
	g_signal_connect_object ((DataCollection*) _tmp5_, "items-altered", (GCallback) _event_page_on_events_altered_data_collection_items_altered, self, 0);
	return self;
}

EventPage*
event_page_new (Event* page_event)
{
	return event_page_construct (TYPE_EVENT_PAGE, page_event);
}

Event*
event_page_get_event (EventPage* self)
{
	Event* _tmp0_;
	Event* _tmp1_;
	Event* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->page_event;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static gboolean
event_page_real_on_app_key_pressed (Page* base,
                                    GdkEventKey* event)
{
	EventPage * self;
	const gchar* _tmp0_;
	gboolean result;
	self = (EventPage*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = gdk_keyval_name (event->keyval);
	if (g_strcmp0 (_tmp0_, "F2") == 0) {
		ViewCollection* _tmp1_;
		ViewCollection* _tmp2_;
		gboolean _tmp3_;
		_tmp1_ = page_get_view ((Page*) self);
		_tmp2_ = _tmp1_;
		_tmp3_ = view_collection_get_selected_count (_tmp2_) != 1;
		_data_collection_unref0 (_tmp2_);
		if (_tmp3_) {
			result = TRUE;
			return result;
		}
	}
	result = PAGE_CLASS (event_page_parent_class)->on_app_key_pressed ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_COLLECTION_PAGE, CollectionPage), event);
	return result;
}

static Block13Data*
block13_data_ref (Block13Data* _data13_)
{
	g_atomic_int_inc (&_data13_->_ref_count_);
	return _data13_;
}

static void
block13_data_unref (void * _userdata_)
{
	Block13Data* _data13_;
	_data13_ = (Block13Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
		EventPage* self;
		self = _data13_->self;
		_g_object_unref0 (_data13_->rename_action);
		_g_object_unref0 (self);
		g_slice_free (Block13Data, _data13_);
	}
}

static void
___lambda55_ (Block13Data* _data13_)
{
	EventPage* self;
	GtkAction* _tmp0_;
	self = _data13_->self;
	_tmp0_ = _data13_->rename_action;
	gtk_action_activate (_tmp0_);
}

static void
____lambda55__gtk_menu_item_activate (GtkMenuItem* _sender,
                                      gpointer self)
{
	___lambda55_ (self);
}

static GtkMenu*
event_page_real_get_page_sidebar_menu (Page* base)
{
	EventPage * self;
	GtkMenu* _tmp0_;
	GtkMenu* _tmp10_;
	GtkMenu* _tmp11_;
	GtkMenu* result;
	self = (EventPage*) base;
	_tmp0_ = self->priv->page_sidebar_menu;
	if (_tmp0_ == NULL) {
		Block13Data* _data13_;
		GtkMenu* _tmp1_;
		GtkMenuItem* rename_menu_item = NULL;
		GtkMenuItem* _tmp2_;
		GtkAction* _tmp3_;
		GtkAction* _tmp4_;
		GtkMenuItem* _tmp5_;
		GtkMenuItem* _tmp6_;
		GtkMenu* _tmp7_;
		GtkMenuItem* _tmp8_;
		GtkMenu* _tmp9_;
		_data13_ = g_slice_new0 (Block13Data);
		_data13_->_ref_count_ = 1;
		_data13_->self = g_object_ref (self);
		_tmp1_ = (GtkMenu*) gtk_menu_new ();
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (self->priv->page_sidebar_menu);
		self->priv->page_sidebar_menu = _tmp1_;
		_tmp2_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic (RESOURCES_RENAME_EVENT_MENU);
		g_object_ref_sink (_tmp2_);
		rename_menu_item = _tmp2_;
		_tmp3_ = page_get_action ((Page*) self, "Rename");
		_data13_->rename_action = _tmp3_;
		_tmp4_ = _data13_->rename_action;
		_tmp5_ = rename_menu_item;
		g_object_bind_property_with_closures ((GObject*) _tmp4_, "sensitive", (GObject*) _tmp5_, "sensitive", 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_ = rename_menu_item;
		g_signal_connect_data (_tmp6_, "activate", (GCallback) ____lambda55__gtk_menu_item_activate, block13_data_ref (_data13_), (GClosureNotify) block13_data_unref, 0);
		_tmp7_ = self->priv->page_sidebar_menu;
		_tmp8_ = rename_menu_item;
		gtk_container_add ((GtkContainer*) _tmp7_, (GtkWidget*) _tmp8_);
		_tmp9_ = self->priv->page_sidebar_menu;
		gtk_widget_show_all ((GtkWidget*) _tmp9_);
		_g_object_unref0 (rename_menu_item);
		block13_data_unref (_data13_);
		_data13_ = NULL;
	}
	_tmp10_ = self->priv->page_sidebar_menu;
	_tmp11_ = _g_object_ref0 (_tmp10_);
	result = _tmp11_;
	return result;
}

static void
_event_page_on_make_primary_gcallback (GtkAction* action,
                                       gpointer self)
{
	event_page_on_make_primary ((EventPage*) self);
}

static void
_vala_array_add148 (GtkActionEntry* * array,
                    gint* length,
                    gint* size,
                    const GtkActionEntry* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GtkActionEntry, *array, *size);
	}
	(*array)[(*length)++] = *value;
}

static void
_event_page_on_rename_gcallback (GtkAction* action,
                                 gpointer self)
{
	event_page_on_rename ((EventPage*) self);
}

static void
_vala_array_add149 (GtkActionEntry* * array,
                    gint* length,
                    gint* size,
                    const GtkActionEntry* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GtkActionEntry, *array, *size);
	}
	(*array)[(*length)++] = *value;
}

static GtkActionEntry*
event_page_real_init_collect_action_entries (Page* base,
                                             gint* result_length1)
{
	EventPage * self;
	GtkActionEntry* new_actions = NULL;
	gint _tmp0_ = 0;
	GtkActionEntry* _tmp1_;
	gint new_actions_length1;
	gint _new_actions_size_;
	GtkActionEntry make_primary = {0};
	GtkActionEntry _tmp2_ = {0};
	GtkActionEntry _tmp3_;
	GtkActionEntry rename = {0};
	GtkActionEntry _tmp4_ = {0};
	GtkActionEntry _tmp5_;
	GtkActionEntry* _tmp6_;
	gint _tmp6__length1;
	GtkActionEntry* result;
	self = (EventPage*) base;
	_tmp1_ = PAGE_CLASS (event_page_parent_class)->init_collect_action_entries ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_COLLECTION_PAGE, CollectionPage), &_tmp0_);
	new_actions = _tmp1_;
	new_actions_length1 = _tmp0_;
	_new_actions_size_ = new_actions_length1;
	_tmp2_.name = "MakePrimary";
	_tmp2_.stock_id = NULL;
	_tmp2_.label = RESOURCES_MAKE_KEY_PHOTO_MENU;
	_tmp2_.accelerator = NULL;
	_tmp2_.tooltip = RESOURCES_MAKE_KEY_PHOTO_MENU;
	_tmp2_.callback = (GCallback) _event_page_on_make_primary_gcallback;
	make_primary = _tmp2_;
	_tmp3_ = make_primary;
	_vala_array_add148 (&new_actions, &new_actions_length1, &_new_actions_size_, &_tmp3_);
	_tmp4_.name = "Rename";
	_tmp4_.stock_id = NULL;
	_tmp4_.label = RESOURCES_RENAME_EVENT_MENU;
	_tmp4_.accelerator = NULL;
	_tmp4_.tooltip = RESOURCES_RENAME_EVENT_MENU;
	_tmp4_.callback = (GCallback) _event_page_on_rename_gcallback;
	rename = _tmp4_;
	_tmp5_ = rename;
	_vala_array_add149 (&new_actions, &new_actions_length1, &_new_actions_size_, &_tmp5_);
	_tmp6_ = new_actions;
	_tmp6__length1 = new_actions_length1;
	if (result_length1) {
		*result_length1 = _tmp6__length1;
	}
	result = _tmp6_;
	return result;
}

static void
event_page_real_init_actions (Page* base,
                              gint selected_count,
                              gint count)
{
	EventPage * self;
	self = (EventPage*) base;
	PAGE_CLASS (event_page_parent_class)->init_actions ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_COLLECTION_PAGE, CollectionPage), selected_count, count);
}

static void
event_page_real_update_actions (Page* base,
                                gint selected_count,
                                gint count)
{
	EventPage * self;
	self = (EventPage*) base;
	page_set_action_sensitive ((Page*) self, "MakePrimary", selected_count == 1);
	page_set_action_visible ((Page*) self, "CommonJumpToEvent", FALSE);
	PAGE_CLASS (event_page_parent_class)->update_actions ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_COLLECTION_PAGE, CollectionPage), selected_count, count);
}

static void
event_page_real_get_config_photos_sort (MediaPage* base,
                                        gboolean* sort_order,
                                        gint* sort_by)
{
	EventPage * self;
	gboolean _vala_sort_order = FALSE;
	gint _vala_sort_by = 0;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	self = (EventPage*) base;
	_tmp0_ = ((Page*) self)->ui_settings;
	_vala_sort_order = g_settings_get_boolean (_tmp0_, "event-photos-sort-ascending");
	_tmp1_ = ((Page*) self)->ui_settings;
	_vala_sort_by = g_settings_get_int (_tmp1_, "event-photos-sort-by");
	if (sort_order) {
		*sort_order = _vala_sort_order;
	}
	if (sort_by) {
		*sort_by = _vala_sort_by;
	}
}

static void
event_page_real_set_config_photos_sort (MediaPage* base,
                                        gboolean sort_order,
                                        gint sort_by)
{
	EventPage * self;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	self = (EventPage*) base;
	_tmp0_ = ((Page*) self)->ui_settings;
	g_settings_set_boolean (_tmp0_, "event-photos-sort-ascending", sort_order);
	_tmp1_ = ((Page*) self)->ui_settings;
	g_settings_set_int (_tmp1_, "event-photos-sort-by", sort_by);
}

static void
event_page_on_events_altered (EventPage* self,
                              GeeMap* map)
{
	Event* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (map != NULL);
	_tmp0_ = self->priv->page_event;
	if (gee_map_has_key (map, (DataObject*) _tmp0_)) {
		Event* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp1_ = self->priv->page_event;
		_tmp2_ = data_object_get_name ((DataObject*) _tmp1_);
		_tmp3_ = _tmp2_;
		page_set_page_name ((Page*) self, _tmp3_);
		_g_free0 (_tmp3_);
	}
}

static void
event_page_on_make_primary (EventPage* self)
{
	ViewCollection* _tmp0_;
	ViewCollection* _tmp1_;
	gboolean _tmp2_;
	Event* _tmp3_;
	ViewCollection* _tmp4_;
	ViewCollection* _tmp5_;
	DataView* _tmp6_;
	DataView* _tmp7_;
	DataSource* _tmp8_;
	DataSource* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = page_get_view ((Page*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = view_collection_get_selected_count (_tmp1_) != 1;
	_data_collection_unref0 (_tmp1_);
	if (_tmp2_) {
		return;
	}
	_tmp3_ = self->priv->page_event;
	_tmp4_ = page_get_view ((Page*) self);
	_tmp5_ = _tmp4_;
	_tmp6_ = view_collection_get_selected_at (_tmp5_, 0);
	_tmp7_ = _tmp6_;
	_tmp8_ = data_view_get_source (_tmp7_);
	_tmp9_ = _tmp8_;
	event_set_primary_source (_tmp3_, G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, TYPE_MEDIA_SOURCE, MediaSource));
	_g_object_unref0 (_tmp7_);
	_data_collection_unref0 (_tmp5_);
}

static void
event_page_on_rename (EventPage* self)
{
	LibraryWindow* _tmp0_;
	LibraryWindow* _tmp1_;
	Event* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = library_window_get_app ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->page_event;
	library_window_rename_event_in_sidebar (_tmp1_, _tmp2_);
	_g_object_unref0 (_tmp1_);
}

static void
_event_page_back_to_master_clicked_gtk_button_clicked (GtkButton* _sender,
                                                       gpointer self)
{
	event_page_back_to_master_clicked ((EventPage*) self);
}

static GtkBox*
event_page_real_get_header_buttons (Page* base)
{
	EventPage * self;
	GtkBox* _tmp0_;
	GtkButton* back_button = NULL;
	GtkButton* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkBox* _tmp3_;
	GtkBox* _tmp4_;
	GtkBox* _tmp5_;
	GtkBox* result;
	self = (EventPage*) base;
	_tmp0_ = PAGE_CLASS (event_page_parent_class)->get_header_buttons ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_COLLECTION_PAGE, CollectionPage));
	_g_object_unref0 (((Page*) self)->header_box);
	((Page*) self)->header_box = _tmp0_;
	_tmp1_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp1_);
	back_button = _tmp1_;
	g_signal_connect_object (back_button, "clicked", (GCallback) _event_page_back_to_master_clicked_gtk_button_clicked, self, 0);
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) back_button);
	gtk_style_context_add_class (_tmp2_, "back-button");
	gtk_widget_set_can_focus ((GtkWidget*) back_button, FALSE);
	gtk_widget_set_valign ((GtkWidget*) back_button, GTK_ALIGN_CENTER);
	gtk_widget_set_vexpand ((GtkWidget*) back_button, FALSE);
	gtk_widget_set_visible ((GtkWidget*) back_button, FALSE);
	gtk_button_set_label (back_button, _ ("All Events"));
	_tmp3_ = ((Page*) self)->header_box;
	gtk_box_pack_start (_tmp3_, (GtkWidget*) back_button, TRUE, TRUE, (guint) 0);
	_tmp4_ = ((Page*) self)->header_box;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	result = _tmp5_;
	_g_object_unref0 (back_button);
	return result;
}

void
event_page_back_to_master_clicked (EventPage* self)
{
	LibraryWindow* app = NULL;
	AppWindow* _tmp0_;
	LibraryWindow* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = app_window_get_instance ();
	_tmp1_ = IS_LIBRARY_WINDOW (_tmp0_) ? ((LibraryWindow*) _tmp0_) : NULL;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (_tmp0_);
	}
	app = _tmp1_;
	library_window_switch_to_event_directory (app);
	_g_object_unref0 (app);
}

static void
event_page_class_init (EventPageClass * klass,
                       gpointer klass_data)
{
	event_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &EventPage_private_offset);
	((PageClass *) klass)->on_app_key_pressed = (gboolean (*) (Page*, GdkEventKey*)) event_page_real_on_app_key_pressed;
	((PageClass *) klass)->get_page_sidebar_menu = (GtkMenu* (*) (Page*)) event_page_real_get_page_sidebar_menu;
	((PageClass *) klass)->init_collect_action_entries = (GtkActionEntry* (*) (Page*, gint*)) event_page_real_init_collect_action_entries;
	((PageClass *) klass)->init_actions = (void (*) (Page*, gint, gint)) event_page_real_init_actions;
	((PageClass *) klass)->update_actions = (void (*) (Page*, gint, gint)) event_page_real_update_actions;
	((MediaPageClass *) klass)->get_config_photos_sort = (void (*) (MediaPage*, gboolean*, gint*)) event_page_real_get_config_photos_sort;
	((MediaPageClass *) klass)->set_config_photos_sort = (void (*) (MediaPage*, gboolean, gint)) event_page_real_set_config_photos_sort;
	((PageClass *) klass)->get_header_buttons = (GtkBox* (*) (Page*)) event_page_real_get_header_buttons;
	G_OBJECT_CLASS (klass)->finalize = event_page_finalize;
}

static void
event_page_instance_init (EventPage * self,
                          gpointer klass)
{
	self->priv = event_page_get_instance_private (self);
}

static void
event_page_finalize (GObject * obj)
{
	EventPage * self;
	EventSourceCollection* _tmp0_;
	guint _tmp1_;
	ViewCollection* _tmp2_;
	ViewCollection* _tmp3_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_EVENT_PAGE, EventPage);
	_tmp0_ = event_global;
	g_signal_parse_name ("items-altered", TYPE_DATA_COLLECTION, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((DataCollection*) _tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _event_page_on_events_altered_data_collection_items_altered, self);
	_tmp2_ = page_get_view ((Page*) self);
	_tmp3_ = _tmp2_;
	view_collection_halt_mirroring (_tmp3_);
	_data_collection_unref0 (_tmp3_);
	_g_object_unref0 (self->priv->page_event);
	_g_object_unref0 (self->priv->page_sidebar_menu);
	G_OBJECT_CLASS (event_page_parent_class)->finalize (obj);
}

static GType
event_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (EventPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) event_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EventPage), 0, (GInstanceInitFunc) event_page_instance_init, NULL };
	GType event_page_type_id;
	event_page_type_id = g_type_register_static (TYPE_COLLECTION_PAGE, "EventPage", &g_define_type_info, 0);
	EventPage_private_offset = g_type_add_instance_private (event_page_type_id, sizeof (EventPagePrivate));
	return event_page_type_id;
}

GType
event_page_get_type (void)
{
	static volatile gsize event_page_type_id__once = 0;
	if (g_once_init_enter (&event_page_type_id__once)) {
		GType event_page_type_id;
		event_page_type_id = event_page_get_type_once ();
		g_once_init_leave (&event_page_type_id__once, event_page_type_id);
	}
	return event_page_type_id__once;
}

NoEventPage*
no_event_page_construct (GType object_type)
{
	NoEventPage * self = NULL;
	ViewManager* filter = NULL;
	NoEventPageNoEventViewManager* _tmp0_;
	ViewCollection* _tmp1_;
	ViewCollection* _tmp2_;
	LibraryPhotoSourceCollection* _tmp3_;
	Alteration* _tmp4_;
	ViewCollectionMonitor* _tmp5_;
	ViewCollectionMonitor* _tmp6_;
	ViewCollection* _tmp7_;
	ViewCollection* _tmp8_;
	VideoSourceCollection* _tmp9_;
	Alteration* _tmp10_;
	ViewCollectionMonitor* _tmp11_;
	ViewCollectionMonitor* _tmp12_;
	self = (NoEventPage*) collection_page_construct (object_type, NO_EVENT_PAGE_NAME);
	_tmp0_ = no_event_page_no_event_view_manager_new (self);
	filter = (ViewManager*) _tmp0_;
	_tmp1_ = page_get_view ((Page*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = library_photo_global;
	_tmp4_ = no_event_page_no_event_page_alteration;
	_tmp5_ = view_collection_monitor_source_collection (_tmp2_, (SourceCollection*) _tmp3_, filter, _tmp4_, NULL, NULL, NULL);
	_tmp6_ = _tmp5_;
	_view_collection_monitor_unref0 (_tmp6_);
	_data_collection_unref0 (_tmp2_);
	_tmp7_ = page_get_view ((Page*) self);
	_tmp8_ = _tmp7_;
	_tmp9_ = video_global;
	_tmp10_ = no_event_page_no_event_page_alteration;
	_tmp11_ = view_collection_monitor_source_collection (_tmp8_, (SourceCollection*) _tmp9_, filter, _tmp10_, NULL, NULL, NULL);
	_tmp12_ = _tmp11_;
	_view_collection_monitor_unref0 (_tmp12_);
	_data_collection_unref0 (_tmp8_);
	_view_manager_unref0 (filter);
	return self;
}

NoEventPage*
no_event_page_new (void)
{
	return no_event_page_construct (TYPE_NO_EVENT_PAGE);
}

static void
no_event_page_real_get_config_photos_sort (MediaPage* base,
                                           gboolean* sort_order,
                                           gint* sort_by)
{
	NoEventPage * self;
	gboolean _vala_sort_order = FALSE;
	gint _vala_sort_by = 0;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	self = (NoEventPage*) base;
	_tmp0_ = ((Page*) self)->ui_settings;
	_vala_sort_order = g_settings_get_boolean (_tmp0_, "event-photos-sort-ascending");
	_tmp1_ = ((Page*) self)->ui_settings;
	_vala_sort_by = g_settings_get_int (_tmp1_, "event-photos-sort-by");
	if (sort_order) {
		*sort_order = _vala_sort_order;
	}
	if (sort_by) {
		*sort_by = _vala_sort_by;
	}
}

static void
no_event_page_real_set_config_photos_sort (MediaPage* base,
                                           gboolean sort_order,
                                           gint sort_by)
{
	NoEventPage * self;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	self = (NoEventPage*) base;
	_tmp0_ = ((Page*) self)->ui_settings;
	g_settings_set_boolean (_tmp0_, "event-photos-sort-ascending", sort_order);
	_tmp1_ = ((Page*) self)->ui_settings;
	g_settings_set_int (_tmp1_, "event-photos-sort-by", sort_by);
}

static NoEventPageNoEventViewManager*
no_event_page_no_event_view_manager_construct (GType object_type,
                                               NoEventPage* page)
{
	NoEventPageNoEventViewManager* self = NULL;
	g_return_val_if_fail (page != NULL, NULL);
	self = (NoEventPageNoEventViewManager*) collection_view_manager_construct (object_type, (CollectionPage*) page);
	return self;
}

static NoEventPageNoEventViewManager*
no_event_page_no_event_view_manager_new (NoEventPage* page)
{
	return no_event_page_no_event_view_manager_construct (NO_EVENT_PAGE_TYPE_NO_EVENT_VIEW_MANAGER, page);
}

static gboolean
no_event_page_no_event_view_manager_real_include_in_view (ViewManager* base,
                                                          DataSource* source)
{
	NoEventPageNoEventViewManager * self;
	gboolean _tmp0_ = FALSE;
	EventID _tmp1_ = {0};
	gboolean result;
	self = (NoEventPageNoEventViewManager*) base;
	g_return_val_if_fail (source != NULL, FALSE);
	media_source_get_event_id (G_TYPE_CHECK_INSTANCE_CAST (source, TYPE_MEDIA_SOURCE, MediaSource), &_tmp1_);
	if (_tmp1_.id != EVENT_ID_INVALID) {
		_tmp0_ = FALSE;
	} else {
		_tmp0_ = VIEW_MANAGER_CLASS (no_event_page_no_event_view_manager_parent_class)->include_in_view ((ViewManager*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_COLLECTION_VIEW_MANAGER, CollectionViewManager), source);
	}
	result = _tmp0_;
	return result;
}

static void
no_event_page_no_event_view_manager_class_init (NoEventPageNoEventViewManagerClass * klass,
                                                gpointer klass_data)
{
	no_event_page_no_event_view_manager_parent_class = g_type_class_peek_parent (klass);
	((ViewManagerClass *) klass)->include_in_view = (gboolean (*) (ViewManager*, DataSource*)) no_event_page_no_event_view_manager_real_include_in_view;
}

static void
no_event_page_no_event_view_manager_instance_init (NoEventPageNoEventViewManager * self,
                                                   gpointer klass)
{
}

static GType
no_event_page_no_event_view_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NoEventPageNoEventViewManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) no_event_page_no_event_view_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NoEventPageNoEventViewManager), 0, (GInstanceInitFunc) no_event_page_no_event_view_manager_instance_init, NULL };
	GType no_event_page_no_event_view_manager_type_id;
	no_event_page_no_event_view_manager_type_id = g_type_register_static (TYPE_COLLECTION_VIEW_MANAGER, "NoEventPageNoEventViewManager", &g_define_type_info, 0);
	return no_event_page_no_event_view_manager_type_id;
}

static GType
no_event_page_no_event_view_manager_get_type (void)
{
	static volatile gsize no_event_page_no_event_view_manager_type_id__once = 0;
	if (g_once_init_enter (&no_event_page_no_event_view_manager_type_id__once)) {
		GType no_event_page_no_event_view_manager_type_id;
		no_event_page_no_event_view_manager_type_id = no_event_page_no_event_view_manager_get_type_once ();
		g_once_init_leave (&no_event_page_no_event_view_manager_type_id__once, no_event_page_no_event_view_manager_type_id);
	}
	return no_event_page_no_event_view_manager_type_id__once;
}

static void
no_event_page_class_init (NoEventPageClass * klass,
                          gpointer klass_data)
{
	Alteration* _tmp0_;
	no_event_page_parent_class = g_type_class_peek_parent (klass);
	((MediaPageClass *) klass)->get_config_photos_sort = (void (*) (MediaPage*, gboolean*, gint*)) no_event_page_real_get_config_photos_sort;
	((MediaPageClass *) klass)->set_config_photos_sort = (void (*) (MediaPage*, gboolean, gint)) no_event_page_real_set_config_photos_sort;
	G_OBJECT_CLASS (klass)->finalize = no_event_page_finalize;
	_tmp0_ = alteration_new ("metadata", "event");
	no_event_page_no_event_page_alteration = _tmp0_;
}

static void
no_event_page_instance_init (NoEventPage * self,
                             gpointer klass)
{
}

static void
no_event_page_finalize (GObject * obj)
{
	NoEventPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NO_EVENT_PAGE, NoEventPage);
	G_OBJECT_CLASS (no_event_page_parent_class)->finalize (obj);
}

static GType
no_event_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NoEventPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) no_event_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NoEventPage), 0, (GInstanceInitFunc) no_event_page_instance_init, NULL };
	GType no_event_page_type_id;
	no_event_page_type_id = g_type_register_static (TYPE_COLLECTION_PAGE, "NoEventPage", &g_define_type_info, 0);
	return no_event_page_type_id;
}

GType
no_event_page_get_type (void)
{
	static volatile gsize no_event_page_type_id__once = 0;
	if (g_once_init_enter (&no_event_page_type_id__once)) {
		GType no_event_page_type_id;
		no_event_page_type_id = no_event_page_get_type_once ();
		g_once_init_leave (&no_event_page_type_id__once, no_event_page_type_id);
	}
	return no_event_page_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

