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

/*
* Copyright (c) 2010-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 <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.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  {
	TAG_PAGE_0_PROPERTY,
	TAG_PAGE_NUM_PROPERTIES
};
static GParamSpec* tag_page_properties[TAG_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 _Block25Data Block25Data;
#define _command_manager_unref0(var) ((var == NULL) ? NULL : (var = (command_manager_unref (var), NULL)))

struct _TagPagePrivate {
	Tag* tag;
	GtkMenu* page_sidebar_menu;
};

struct _Block25Data {
	int _ref_count_;
	TagPage* self;
	GtkAction* new_child_action;
	GtkAction* rename_action;
	GtkAction* delete_action;
};

static gint TagPage_private_offset;
static gpointer tag_page_parent_class = NULL;

static void tag_page_on_tags_altered (TagPage* self,
                               GeeMap* map);
static void _tag_page_on_tags_altered_data_collection_items_altered (DataCollection* _sender,
                                                              GeeMap* items,
                                                              gpointer self);
static DataView* _media_page_create_thumbnail_create_view (DataSource* source,
                                                    gpointer self);
static GtkMenu* tag_page_real_get_page_sidebar_menu (Page* base);
static Block25Data* block25_data_ref (Block25Data* _data25_);
static void block25_data_unref (void * _userdata_);
static void ___lambda99_ (Block25Data* _data25_);
static void ____lambda99__gtk_menu_item_activate (GtkMenuItem* _sender,
                                           gpointer self);
static void ___lambda100_ (Block25Data* _data25_);
static void ____lambda100__gtk_menu_item_activate (GtkMenuItem* _sender,
                                            gpointer self);
static void ___lambda101_ (Block25Data* _data25_);
static void ____lambda101__gtk_menu_item_activate (GtkMenuItem* _sender,
                                            gpointer self);
static void tag_page_real_get_config_photos_sort (MediaPage* base,
                                           gboolean* sort_order,
                                           gint* sort_by);
static void tag_page_real_set_config_photos_sort (MediaPage* base,
                                           gboolean sort_order,
                                           gint sort_by);
static GtkActionEntry* tag_page_real_init_collect_action_entries (Page* base,
                                                           gint* result_length1);
static void tag_page_on_delete_tag (TagPage* self);
static void _tag_page_on_delete_tag_gcallback (GtkAction* action,
                                        gpointer self);
static void _vala_array_add215 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void tag_page_on_rename_tag (TagPage* self);
static void _tag_page_on_rename_tag_gcallback (GtkAction* action,
                                        gpointer self);
static void _vala_array_add216 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void tag_page_on_remove_tag_from_photos (TagPage* self);
static void _tag_page_on_remove_tag_from_photos_gcallback (GtkAction* action,
                                                    gpointer self);
static void _vala_array_add217 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void _vala_array_add218 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void _vala_array_add219 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void tag_page_on_new_child_tag_sidebar (TagPage* self);
static void _tag_page_on_new_child_tag_sidebar_gcallback (GtkAction* action,
                                                   gpointer self);
static void _vala_array_add220 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void tag_page_real_update_actions (Page* base,
                                   gint selected_count,
                                   gint count);
static void tag_page_finalize (GObject * obj);
static GType tag_page_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
tag_page_get_instance_private (TagPage* self)
{
	return G_STRUCT_MEMBER_P (self, TagPage_private_offset);
}

static void
_tag_page_on_tags_altered_data_collection_items_altered (DataCollection* _sender,
                                                         GeeMap* items,
                                                         gpointer self)
{
	tag_page_on_tags_altered ((TagPage*) 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;
}

TagPage*
tag_page_construct (GType object_type,
                    Tag* tag)
{
	TagPage * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	Tag* _tmp2_;
	TagSourceCollection* _tmp3_;
	ViewCollection* _tmp4_;
	ViewCollection* _tmp5_;
	g_return_val_if_fail (tag != NULL, NULL);
	_tmp0_ = data_object_get_name ((DataObject*) tag);
	_tmp1_ = _tmp0_;
	self = (TagPage*) collection_page_construct (object_type, _tmp1_);
	_g_free0 (_tmp1_);
	_tmp2_ = _g_object_ref0 (tag);
	_g_object_unref0 (self->priv->tag);
	self->priv->tag = _tmp2_;
	_tmp3_ = tag_global;
	g_signal_connect_object ((DataCollection*) _tmp3_, "items-altered", (GCallback) _tag_page_on_tags_altered_data_collection_items_altered, self, 0);
	_tmp4_ = page_get_view ((Page*) self);
	_tmp5_ = _tmp4_;
	tag_mirror_sources (tag, _tmp5_, _media_page_create_thumbnail_create_view, (MediaPage*) self);
	_data_collection_unref0 (_tmp5_);
	return self;
}

TagPage*
tag_page_new (Tag* tag)
{
	return tag_page_construct (TYPE_TAG_PAGE, tag);
}

static Block25Data*
block25_data_ref (Block25Data* _data25_)
{
	g_atomic_int_inc (&_data25_->_ref_count_);
	return _data25_;
}

static void
block25_data_unref (void * _userdata_)
{
	Block25Data* _data25_;
	_data25_ = (Block25Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data25_->_ref_count_)) {
		TagPage* self;
		self = _data25_->self;
		_g_object_unref0 (_data25_->delete_action);
		_g_object_unref0 (_data25_->rename_action);
		_g_object_unref0 (_data25_->new_child_action);
		_g_object_unref0 (self);
		g_slice_free (Block25Data, _data25_);
	}
}

static void
___lambda99_ (Block25Data* _data25_)
{
	TagPage* self;
	GtkAction* _tmp0_;
	self = _data25_->self;
	_tmp0_ = _data25_->new_child_action;
	gtk_action_activate (_tmp0_);
}

static void
____lambda99__gtk_menu_item_activate (GtkMenuItem* _sender,
                                      gpointer self)
{
	___lambda99_ (self);
}

static void
___lambda100_ (Block25Data* _data25_)
{
	TagPage* self;
	GtkAction* _tmp0_;
	self = _data25_->self;
	_tmp0_ = _data25_->rename_action;
	gtk_action_activate (_tmp0_);
}

static void
____lambda100__gtk_menu_item_activate (GtkMenuItem* _sender,
                                       gpointer self)
{
	___lambda100_ (self);
}

static void
___lambda101_ (Block25Data* _data25_)
{
	TagPage* self;
	GtkAction* _tmp0_;
	self = _data25_->self;
	_tmp0_ = _data25_->delete_action;
	gtk_action_activate (_tmp0_);
}

static void
____lambda101__gtk_menu_item_activate (GtkMenuItem* _sender,
                                       gpointer self)
{
	___lambda101_ (self);
}

static GtkMenu*
tag_page_real_get_page_sidebar_menu (Page* base)
{
	TagPage * self;
	GtkMenu* _tmp0_;
	GtkMenu* _tmp27_;
	GtkMenu* _tmp28_;
	GtkMenu* result;
	self = (TagPage*) base;
	_tmp0_ = self->priv->page_sidebar_menu;
	if (_tmp0_ == NULL) {
		Block25Data* _data25_;
		GtkMenu* _tmp1_;
		GtkMenuItem* new_child_menu_item = NULL;
		GtkMenuItem* _tmp2_;
		GtkAction* _tmp3_;
		GtkAction* _tmp4_;
		GtkMenuItem* _tmp5_;
		GtkMenuItem* _tmp6_;
		GtkMenuItem* rename_menu_item = NULL;
		GtkMenuItem* _tmp7_;
		GtkAction* _tmp8_;
		GtkAction* _tmp9_;
		GtkMenuItem* _tmp10_;
		GtkMenuItem* _tmp11_;
		GtkMenuItem* delete_menu_item = NULL;
		GtkMenuItem* _tmp12_;
		GtkAction* _tmp13_;
		GtkAction* _tmp14_;
		GtkMenuItem* _tmp15_;
		GtkMenuItem* _tmp16_;
		GtkMenu* _tmp17_;
		GtkMenuItem* _tmp18_;
		GtkMenu* _tmp19_;
		GtkSeparatorMenuItem* _tmp20_;
		GtkSeparatorMenuItem* _tmp21_;
		GtkMenu* _tmp22_;
		GtkMenuItem* _tmp23_;
		GtkMenu* _tmp24_;
		GtkMenuItem* _tmp25_;
		GtkMenu* _tmp26_;
		_data25_ = g_slice_new0 (Block25Data);
		_data25_->_ref_count_ = 1;
		_data25_->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_NEW_CHILD_TAG_SIDEBAR_MENU);
		g_object_ref_sink (_tmp2_);
		new_child_menu_item = _tmp2_;
		_tmp3_ = page_get_action ((Page*) self, "NewChildTagSidebar");
		_data25_->new_child_action = _tmp3_;
		_tmp4_ = _data25_->new_child_action;
		_tmp5_ = new_child_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_ = new_child_menu_item;
		g_signal_connect_data (_tmp6_, "activate", (GCallback) ____lambda99__gtk_menu_item_activate, block25_data_ref (_data25_), (GClosureNotify) block25_data_unref, 0);
		_tmp7_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic (RESOURCES_RENAME_TAG_SIDEBAR_MENU);
		g_object_ref_sink (_tmp7_);
		rename_menu_item = _tmp7_;
		_tmp8_ = page_get_action ((Page*) self, "RenameTagSidebar");
		_data25_->rename_action = _tmp8_;
		_tmp9_ = _data25_->rename_action;
		_tmp10_ = rename_menu_item;
		g_object_bind_property_with_closures ((GObject*) _tmp9_, "sensitive", (GObject*) _tmp10_, "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)));
		_tmp11_ = rename_menu_item;
		g_signal_connect_data (_tmp11_, "activate", (GCallback) ____lambda100__gtk_menu_item_activate, block25_data_ref (_data25_), (GClosureNotify) block25_data_unref, 0);
		_tmp12_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic (RESOURCES_DELETE_TAG_SIDEBAR_MENU);
		g_object_ref_sink (_tmp12_);
		delete_menu_item = _tmp12_;
		_tmp13_ = page_get_action ((Page*) self, "DeleteTagSidebar");
		_data25_->delete_action = _tmp13_;
		_tmp14_ = _data25_->delete_action;
		_tmp15_ = delete_menu_item;
		g_object_bind_property_with_closures ((GObject*) _tmp14_, "sensitive", (GObject*) _tmp15_, "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)));
		_tmp16_ = delete_menu_item;
		g_signal_connect_data (_tmp16_, "activate", (GCallback) ____lambda101__gtk_menu_item_activate, block25_data_ref (_data25_), (GClosureNotify) block25_data_unref, 0);
		_tmp17_ = self->priv->page_sidebar_menu;
		_tmp18_ = new_child_menu_item;
		gtk_container_add ((GtkContainer*) _tmp17_, (GtkWidget*) _tmp18_);
		_tmp19_ = self->priv->page_sidebar_menu;
		_tmp20_ = (GtkSeparatorMenuItem*) gtk_separator_menu_item_new ();
		g_object_ref_sink (_tmp20_);
		_tmp21_ = _tmp20_;
		gtk_container_add ((GtkContainer*) _tmp19_, (GtkWidget*) _tmp21_);
		_g_object_unref0 (_tmp21_);
		_tmp22_ = self->priv->page_sidebar_menu;
		_tmp23_ = rename_menu_item;
		gtk_container_add ((GtkContainer*) _tmp22_, (GtkWidget*) _tmp23_);
		_tmp24_ = self->priv->page_sidebar_menu;
		_tmp25_ = delete_menu_item;
		gtk_container_add ((GtkContainer*) _tmp24_, (GtkWidget*) _tmp25_);
		_tmp26_ = self->priv->page_sidebar_menu;
		gtk_widget_show_all ((GtkWidget*) _tmp26_);
		_g_object_unref0 (delete_menu_item);
		_g_object_unref0 (rename_menu_item);
		_g_object_unref0 (new_child_menu_item);
		block25_data_unref (_data25_);
		_data25_ = NULL;
	}
	_tmp27_ = self->priv->page_sidebar_menu;
	_tmp28_ = _g_object_ref0 (_tmp27_);
	result = _tmp28_;
	return result;
}

Tag*
tag_page_get_tag (TagPage* self)
{
	Tag* _tmp0_;
	Tag* _tmp1_;
	Tag* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->tag;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
tag_page_real_get_config_photos_sort (MediaPage* base,
                                      gboolean* sort_order,
                                      gint* sort_by)
{
	TagPage * self;
	gboolean _vala_sort_order = FALSE;
	gint _vala_sort_by = 0;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	self = (TagPage*) 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
tag_page_real_set_config_photos_sort (MediaPage* base,
                                      gboolean sort_order,
                                      gint sort_by)
{
	TagPage * self;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	self = (TagPage*) 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
_tag_page_on_delete_tag_gcallback (GtkAction* action,
                                   gpointer self)
{
	tag_page_on_delete_tag ((TagPage*) self);
}

static void
_vala_array_add215 (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
_tag_page_on_rename_tag_gcallback (GtkAction* action,
                                   gpointer self)
{
	tag_page_on_rename_tag ((TagPage*) self);
}

static void
_vala_array_add216 (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
_tag_page_on_remove_tag_from_photos_gcallback (GtkAction* action,
                                               gpointer self)
{
	tag_page_on_remove_tag_from_photos ((TagPage*) self);
}

static void
_vala_array_add217 (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
_vala_array_add218 (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
_vala_array_add219 (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
_tag_page_on_new_child_tag_sidebar_gcallback (GtkAction* action,
                                              gpointer self)
{
	tag_page_on_new_child_tag_sidebar ((TagPage*) self);
}

static void
_vala_array_add220 (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*
tag_page_real_init_collect_action_entries (Page* base,
                                           gint* result_length1)
{
	TagPage * self;
	GtkActionEntry* actions = NULL;
	gint _tmp0_ = 0;
	GtkActionEntry* _tmp1_;
	gint actions_length1;
	gint _actions_size_;
	GtkActionEntry delete_tag = {0};
	GtkActionEntry _tmp2_ = {0};
	GtkActionEntry _tmp3_;
	GtkActionEntry rename_tag = {0};
	GtkActionEntry _tmp4_ = {0};
	GtkActionEntry _tmp5_;
	GtkActionEntry remove_tag = {0};
	GtkActionEntry _tmp6_ = {0};
	GtkActionEntry _tmp7_;
	GtkActionEntry delete_tag_sidebar = {0};
	GtkActionEntry _tmp8_ = {0};
	GtkActionEntry _tmp9_;
	GtkActionEntry rename_tag_sidebar = {0};
	GtkActionEntry _tmp10_ = {0};
	GtkActionEntry _tmp11_;
	GtkActionEntry new_child_tag_sidebar = {0};
	GtkActionEntry _tmp12_ = {0};
	GtkActionEntry _tmp13_;
	GtkActionEntry* _tmp14_;
	gint _tmp14__length1;
	GtkActionEntry* result;
	self = (TagPage*) base;
	_tmp1_ = PAGE_CLASS (tag_page_parent_class)->init_collect_action_entries ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_COLLECTION_PAGE, CollectionPage), &_tmp0_);
	actions = _tmp1_;
	actions_length1 = _tmp0_;
	_actions_size_ = actions_length1;
	_tmp2_.name = "DeleteTag";
	_tmp2_.stock_id = NULL;
	_tmp2_.label = TRANSLATABLE;
	_tmp2_.accelerator = NULL;
	_tmp2_.tooltip = NULL;
	_tmp2_.callback = (GCallback) _tag_page_on_delete_tag_gcallback;
	delete_tag = _tmp2_;
	_tmp3_ = delete_tag;
	_vala_array_add215 (&actions, &actions_length1, &_actions_size_, &_tmp3_);
	_tmp4_.name = "RenameTag";
	_tmp4_.stock_id = NULL;
	_tmp4_.label = TRANSLATABLE;
	_tmp4_.accelerator = NULL;
	_tmp4_.tooltip = NULL;
	_tmp4_.callback = (GCallback) _tag_page_on_rename_tag_gcallback;
	rename_tag = _tmp4_;
	_tmp5_ = rename_tag;
	_vala_array_add216 (&actions, &actions_length1, &_actions_size_, &_tmp5_);
	_tmp6_.name = "RemoveTagFromPhotos";
	_tmp6_.stock_id = NULL;
	_tmp6_.label = TRANSLATABLE;
	_tmp6_.accelerator = NULL;
	_tmp6_.tooltip = NULL;
	_tmp6_.callback = (GCallback) _tag_page_on_remove_tag_from_photos_gcallback;
	remove_tag = _tmp6_;
	_tmp7_ = remove_tag;
	_vala_array_add217 (&actions, &actions_length1, &_actions_size_, &_tmp7_);
	_tmp8_.name = "DeleteTagSidebar";
	_tmp8_.stock_id = NULL;
	_tmp8_.label = RESOURCES_DELETE_TAG_SIDEBAR_MENU;
	_tmp8_.accelerator = NULL;
	_tmp8_.tooltip = NULL;
	_tmp8_.callback = (GCallback) _tag_page_on_delete_tag_gcallback;
	delete_tag_sidebar = _tmp8_;
	_tmp9_ = delete_tag_sidebar;
	_vala_array_add218 (&actions, &actions_length1, &_actions_size_, &_tmp9_);
	_tmp10_.name = "RenameTagSidebar";
	_tmp10_.stock_id = NULL;
	_tmp10_.label = RESOURCES_RENAME_TAG_SIDEBAR_MENU;
	_tmp10_.accelerator = NULL;
	_tmp10_.tooltip = NULL;
	_tmp10_.callback = (GCallback) _tag_page_on_rename_tag_gcallback;
	rename_tag_sidebar = _tmp10_;
	_tmp11_ = rename_tag_sidebar;
	_vala_array_add219 (&actions, &actions_length1, &_actions_size_, &_tmp11_);
	_tmp12_.name = "NewChildTagSidebar";
	_tmp12_.stock_id = NULL;
	_tmp12_.label = RESOURCES_NEW_CHILD_TAG_SIDEBAR_MENU;
	_tmp12_.accelerator = NULL;
	_tmp12_.tooltip = NULL;
	_tmp12_.callback = (GCallback) _tag_page_on_new_child_tag_sidebar_gcallback;
	new_child_tag_sidebar = _tmp12_;
	_tmp13_ = new_child_tag_sidebar;
	_vala_array_add220 (&actions, &actions_length1, &_actions_size_, &_tmp13_);
	_tmp14_ = actions;
	_tmp14__length1 = actions_length1;
	if (result_length1) {
		*result_length1 = _tmp14__length1;
	}
	result = _tmp14_;
	return result;
}

static void
tag_page_on_tags_altered (TagPage* self,
                          GeeMap* map)
{
	Tag* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (map != NULL);
	_tmp0_ = self->priv->tag;
	if (gee_map_has_key (map, (DataObject*) _tmp0_)) {
		Tag* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		ViewCollection* _tmp4_;
		ViewCollection* _tmp5_;
		ViewCollection* _tmp6_;
		ViewCollection* _tmp7_;
		_tmp1_ = self->priv->tag;
		_tmp2_ = data_object_get_name ((DataObject*) _tmp1_);
		_tmp3_ = _tmp2_;
		page_set_page_name ((Page*) self, _tmp3_);
		_g_free0 (_tmp3_);
		_tmp4_ = page_get_view ((Page*) self);
		_tmp5_ = _tmp4_;
		_tmp6_ = page_get_view ((Page*) self);
		_tmp7_ = _tmp6_;
		page_update_actions ((Page*) self, view_collection_get_selected_count (_tmp5_), data_collection_get_count ((DataCollection*) _tmp7_));
		_data_collection_unref0 (_tmp7_);
		_data_collection_unref0 (_tmp5_);
	}
}

static void
tag_page_real_update_actions (Page* base,
                              gint selected_count,
                              gint count)
{
	TagPage * self;
	Tag* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	Tag* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	Tag* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	self = (TagPage*) base;
	_tmp0_ = self->priv->tag;
	_tmp1_ = tag_get_user_visible_name (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = resources_delete_tag_menu (_tmp2_);
	_tmp4_ = _tmp3_;
	collection_page_set_action_details ((CollectionPage*) self, "DeleteTag", _tmp4_, NULL, TRUE);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	_tmp5_ = self->priv->tag;
	_tmp6_ = tag_get_user_visible_name (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = resources_rename_tag_menu (_tmp7_);
	_tmp9_ = _tmp8_;
	collection_page_set_action_details ((CollectionPage*) self, "RenameTag", _tmp9_, NULL, TRUE);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_tmp10_ = self->priv->tag;
	_tmp11_ = tag_get_user_visible_name (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = resources_untag_photos_menu (_tmp12_, selected_count);
	_tmp14_ = _tmp13_;
	collection_page_set_action_details ((CollectionPage*) self, "RemoveTagFromPhotos", _tmp14_, NULL, selected_count > 0);
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	PAGE_CLASS (tag_page_parent_class)->update_actions ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_COLLECTION_PAGE, CollectionPage), selected_count, count);
}

static void
tag_page_on_new_child_tag_sidebar (TagPage* self)
{
	NewChildTagCommand* creation_command = NULL;
	Tag* _tmp0_;
	NewChildTagCommand* _tmp1_;
	CommandManager* _tmp2_;
	CommandManager* _tmp3_;
	LibraryWindow* _tmp4_;
	LibraryWindow* _tmp5_;
	Tag* _tmp6_;
	Tag* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->tag;
	_tmp1_ = new_child_tag_command_new (_tmp0_);
	creation_command = _tmp1_;
	_tmp2_ = app_window_get_command_manager ();
	_tmp3_ = _tmp2_;
	command_manager_execute (_tmp3_, (Command*) creation_command);
	_command_manager_unref0 (_tmp3_);
	_tmp4_ = library_window_get_app ();
	_tmp5_ = _tmp4_;
	_tmp6_ = new_child_tag_command_get_created_child (creation_command);
	_tmp7_ = _tmp6_;
	library_window_rename_tag_in_sidebar (_tmp5_, _tmp7_);
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (creation_command);
}

static void
tag_page_on_rename_tag (TagPage* self)
{
	LibraryWindow* _tmp0_;
	LibraryWindow* _tmp1_;
	Tag* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = library_window_get_app ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->tag;
	library_window_rename_tag_in_sidebar (_tmp1_, _tmp2_);
	_g_object_unref0 (_tmp1_);
}

static void
tag_page_on_delete_tag (TagPage* self)
{
	Tag* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->tag;
	if (dialogs_confirm_delete_tag (_tmp0_)) {
		CommandManager* _tmp1_;
		CommandManager* _tmp2_;
		Tag* _tmp3_;
		DeleteTagCommand* _tmp4_;
		DeleteTagCommand* _tmp5_;
		_tmp1_ = app_window_get_command_manager ();
		_tmp2_ = _tmp1_;
		_tmp3_ = self->priv->tag;
		_tmp4_ = delete_tag_command_new (_tmp3_);
		_tmp5_ = _tmp4_;
		command_manager_execute (_tmp2_, (Command*) _tmp5_);
		_g_object_unref0 (_tmp5_);
		_command_manager_unref0 (_tmp2_);
	}
}

static void
tag_page_on_remove_tag_from_photos (TagPage* self)
{
	ViewCollection* _tmp0_;
	ViewCollection* _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = page_get_view ((Page*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = view_collection_get_selected_count (_tmp1_) > 0;
	_data_collection_unref0 (_tmp1_);
	if (_tmp2_) {
		CommandManager* _tmp3_;
		CommandManager* _tmp4_;
		Tag* _tmp5_;
		ViewCollection* _tmp6_;
		ViewCollection* _tmp7_;
		GeeList* _tmp8_;
		GeeCollection* _tmp9_;
		ViewCollection* _tmp10_;
		ViewCollection* _tmp11_;
		TagUntagPhotosCommand* _tmp12_;
		TagUntagPhotosCommand* _tmp13_;
		_tmp3_ = page_get_command_manager ((Page*) self);
		_tmp4_ = _tmp3_;
		_tmp5_ = self->priv->tag;
		_tmp6_ = page_get_view ((Page*) self);
		_tmp7_ = _tmp6_;
		_tmp8_ = view_collection_get_selected_sources (_tmp7_);
		_tmp9_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_COLLECTION, GeeCollection);
		_tmp10_ = page_get_view ((Page*) self);
		_tmp11_ = _tmp10_;
		_tmp12_ = tag_untag_photos_command_new (_tmp5_, _tmp9_, view_collection_get_selected_count (_tmp11_), FALSE);
		_tmp13_ = _tmp12_;
		command_manager_execute (_tmp4_, (Command*) _tmp13_);
		_g_object_unref0 (_tmp13_);
		_data_collection_unref0 (_tmp11_);
		_g_object_unref0 (_tmp9_);
		_data_collection_unref0 (_tmp7_);
		_command_manager_unref0 (_tmp4_);
	}
}

static void
tag_page_class_init (TagPageClass * klass,
                     gpointer klass_data)
{
	tag_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TagPage_private_offset);
	((PageClass *) klass)->get_page_sidebar_menu = (GtkMenu* (*) (Page*)) tag_page_real_get_page_sidebar_menu;
	((MediaPageClass *) klass)->get_config_photos_sort = (void (*) (MediaPage*, gboolean*, gint*)) tag_page_real_get_config_photos_sort;
	((MediaPageClass *) klass)->set_config_photos_sort = (void (*) (MediaPage*, gboolean, gint)) tag_page_real_set_config_photos_sort;
	((PageClass *) klass)->init_collect_action_entries = (GtkActionEntry* (*) (Page*, gint*)) tag_page_real_init_collect_action_entries;
	((PageClass *) klass)->update_actions = (void (*) (Page*, gint, gint)) tag_page_real_update_actions;
	G_OBJECT_CLASS (klass)->finalize = tag_page_finalize;
}

static void
tag_page_instance_init (TagPage * self,
                        gpointer klass)
{
	self->priv = tag_page_get_instance_private (self);
}

static void
tag_page_finalize (GObject * obj)
{
	TagPage * self;
	ViewCollection* _tmp0_;
	ViewCollection* _tmp1_;
	TagSourceCollection* _tmp2_;
	guint _tmp3_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_TAG_PAGE, TagPage);
	_tmp0_ = page_get_view ((Page*) self);
	_tmp1_ = _tmp0_;
	view_collection_halt_mirroring (_tmp1_);
	_data_collection_unref0 (_tmp1_);
	_tmp2_ = tag_global;
	g_signal_parse_name ("items-altered", TYPE_DATA_COLLECTION, &_tmp3_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((DataCollection*) _tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _tag_page_on_tags_altered_data_collection_items_altered, self);
	_g_object_unref0 (self->priv->tag);
	_g_object_unref0 (self->priv->page_sidebar_menu);
	G_OBJECT_CLASS (tag_page_parent_class)->finalize (obj);
}

static GType
tag_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TagPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tag_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TagPage), 0, (GInstanceInitFunc) tag_page_instance_init, NULL };
	GType tag_page_type_id;
	tag_page_type_id = g_type_register_static (TYPE_COLLECTION_PAGE, "TagPage", &g_define_type_info, 0);
	TagPage_private_offset = g_type_add_instance_private (tag_page_type_id, sizeof (TagPagePrivate));
	return tag_page_type_id;
}

GType
tag_page_get_type (void)
{
	static volatile gsize tag_page_type_id__once = 0;
	if (g_once_init_enter (&tag_page_type_id__once)) {
		GType tag_page_type_id;
		tag_page_type_id = tag_page_get_type_once ();
		g_once_init_leave (&tag_page_type_id__once, tag_page_type_id);
	}
	return tag_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;
}

