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

/*
* Copyright (c) 2011-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
*/
/* Source monitoring for saved searches.*/

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

#define TYPE_SAVED_SEARCH_MANAGER (saved_search_manager_get_type ())
#define SAVED_SEARCH_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SAVED_SEARCH_MANAGER, SavedSearchManager))
#define SAVED_SEARCH_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SAVED_SEARCH_MANAGER, SavedSearchManagerClass))
#define IS_SAVED_SEARCH_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SAVED_SEARCH_MANAGER))
#define IS_SAVED_SEARCH_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SAVED_SEARCH_MANAGER))
#define SAVED_SEARCH_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SAVED_SEARCH_MANAGER, SavedSearchManagerClass))

typedef struct _SavedSearchManager SavedSearchManager;
typedef struct _SavedSearchManagerClass SavedSearchManagerClass;
typedef struct _SavedSearchManagerPrivate SavedSearchManagerPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	SAVED_SEARCH_PAGE_0_PROPERTY,
	SAVED_SEARCH_PAGE_NUM_PROPERTIES
};
static GParamSpec* saved_search_page_properties[SAVED_SEARCH_PAGE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _media_collection_registry_unref0(var) ((var == NULL) ? NULL : (var = (media_collection_registry_unref (var), NULL)))
#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)))
#define _data_collection_unref0(var) ((var == NULL) ? NULL : (var = (data_collection_unref (var), NULL)))
typedef struct _Block23Data Block23Data;
#define _command_manager_unref0(var) ((var == NULL) ? NULL : (var = (command_manager_unref (var), NULL)))

struct _SavedSearchManager {
	CollectionViewManager parent_instance;
	SavedSearchManagerPrivate * priv;
};

struct _SavedSearchManagerClass {
	CollectionViewManagerClass parent_class;
};

struct _SavedSearchManagerPrivate {
	SavedSearch* search;
};

struct _SavedSearchPagePrivate {
	SavedSearch* search;
	GtkMenu* page_sidebar_menu;
};

struct _Block23Data {
	int _ref_count_;
	SavedSearchPage* self;
	GtkAction* rename_action;
	GtkAction* edit_action;
	GtkAction* delete_action;
};

static gint SavedSearchManager_private_offset;
static gpointer saved_search_manager_parent_class = NULL;
static gint SavedSearchPage_private_offset;
static gpointer saved_search_page_parent_class = NULL;

VALA_EXTERN GType saved_search_manager_get_type (void) G_GNUC_CONST ;
VALA_EXTERN SavedSearchManager* saved_search_manager_new (SavedSearchPage* owner,
                                              SavedSearch* search);
VALA_EXTERN SavedSearchManager* saved_search_manager_construct (GType object_type,
                                                    SavedSearchPage* owner,
                                                    SavedSearch* search);
static gboolean saved_search_manager_real_include_in_view (ViewManager* base,
                                                    DataSource* source);
static void saved_search_manager_finalize (ViewManager * obj);
static GType saved_search_manager_get_type_once (void);
static GtkMenu* saved_search_page_real_get_page_sidebar_menu (Page* base);
static Block23Data* block23_data_ref (Block23Data* _data23_);
static void block23_data_unref (void * _userdata_);
static void ___lambda94_ (Block23Data* _data23_);
static void ____lambda94__gtk_menu_item_activate (GtkMenuItem* _sender,
                                           gpointer self);
static void ___lambda95_ (Block23Data* _data23_);
static void ____lambda95__gtk_menu_item_activate (GtkMenuItem* _sender,
                                           gpointer self);
static void ___lambda96_ (Block23Data* _data23_);
static void ____lambda96__gtk_menu_item_activate (GtkMenuItem* _sender,
                                           gpointer self);
static GtkActionEntry* saved_search_page_real_init_collect_action_entries (Page* base,
                                                                    gint* result_length1);
static void saved_search_page_on_rename_search (SavedSearchPage* self);
static void _saved_search_page_on_rename_search_gcallback (GtkAction* action,
                                                    gpointer self);
static void _vala_array_add212 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void saved_search_page_on_edit_search (SavedSearchPage* self);
static void _saved_search_page_on_edit_search_gcallback (GtkAction* action,
                                                  gpointer self);
static void _vala_array_add213 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void saved_search_page_on_delete_search (SavedSearchPage* self);
static void _saved_search_page_on_delete_search_gcallback (GtkAction* action,
                                                    gpointer self);
static void _vala_array_add214 (GtkActionEntry* * array,
                         gint* length,
                         gint* size,
                         const GtkActionEntry* value);
static void saved_search_page_real_update_actions (Page* base,
                                            gint selected_count,
                                            gint count);
static void saved_search_page_finalize (GObject * obj);
static GType saved_search_page_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
saved_search_manager_get_instance_private (SavedSearchManager* self)
{
	return G_STRUCT_MEMBER_P (self, SavedSearchManager_private_offset);
}

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

SavedSearchManager*
saved_search_manager_construct (GType object_type,
                                SavedSearchPage* owner,
                                SavedSearch* search)
{
	SavedSearchManager* self = NULL;
	SavedSearch* _tmp0_;
	g_return_val_if_fail (owner != NULL, NULL);
	g_return_val_if_fail (search != NULL, NULL);
	self = (SavedSearchManager*) collection_view_manager_construct (object_type, (CollectionPage*) owner);
	_tmp0_ = _g_object_ref0 (search);
	_g_object_unref0 (self->priv->search);
	self->priv->search = _tmp0_;
	return self;
}

SavedSearchManager*
saved_search_manager_new (SavedSearchPage* owner,
                          SavedSearch* search)
{
	return saved_search_manager_construct (TYPE_SAVED_SEARCH_MANAGER, owner, search);
}

static gboolean
saved_search_manager_real_include_in_view (ViewManager* base,
                                           DataSource* source)
{
	SavedSearchManager * self;
	SavedSearch* _tmp0_;
	gboolean result;
	self = (SavedSearchManager*) base;
	g_return_val_if_fail (source != NULL, FALSE);
	_tmp0_ = self->priv->search;
	result = saved_search_predicate (_tmp0_, G_TYPE_CHECK_INSTANCE_CAST (source, TYPE_MEDIA_SOURCE, MediaSource));
	return result;
}

static void
saved_search_manager_class_init (SavedSearchManagerClass * klass,
                                 gpointer klass_data)
{
	saved_search_manager_parent_class = g_type_class_peek_parent (klass);
	((ViewManagerClass *) klass)->finalize = saved_search_manager_finalize;
	g_type_class_adjust_private_offset (klass, &SavedSearchManager_private_offset);
	((ViewManagerClass *) klass)->include_in_view = (gboolean (*) (ViewManager*, DataSource*)) saved_search_manager_real_include_in_view;
}

static void
saved_search_manager_instance_init (SavedSearchManager * self,
                                    gpointer klass)
{
	self->priv = saved_search_manager_get_instance_private (self);
}

static void
saved_search_manager_finalize (ViewManager * obj)
{
	SavedSearchManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SAVED_SEARCH_MANAGER, SavedSearchManager);
	_g_object_unref0 (self->priv->search);
	VIEW_MANAGER_CLASS (saved_search_manager_parent_class)->finalize (obj);
}

static GType
saved_search_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SavedSearchManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) saved_search_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SavedSearchManager), 0, (GInstanceInitFunc) saved_search_manager_instance_init, NULL };
	GType saved_search_manager_type_id;
	saved_search_manager_type_id = g_type_register_static (TYPE_COLLECTION_VIEW_MANAGER, "SavedSearchManager", &g_define_type_info, 0);
	SavedSearchManager_private_offset = g_type_add_instance_private (saved_search_manager_type_id, sizeof (SavedSearchManagerPrivate));
	return saved_search_manager_type_id;
}

GType
saved_search_manager_get_type (void)
{
	static volatile gsize saved_search_manager_type_id__once = 0;
	if (g_once_init_enter (&saved_search_manager_type_id__once)) {
		GType saved_search_manager_type_id;
		saved_search_manager_type_id = saved_search_manager_get_type_once ();
		g_once_init_leave (&saved_search_manager_type_id__once, saved_search_manager_type_id);
	}
	return saved_search_manager_type_id__once;
}

static inline gpointer
saved_search_page_get_instance_private (SavedSearchPage* self)
{
	return G_STRUCT_MEMBER_P (self, SavedSearchPage_private_offset);
}

SavedSearchPage*
saved_search_page_construct (GType object_type,
                             SavedSearch* search)
{
	SavedSearchPage * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	SavedSearch* _tmp2_;
	g_return_val_if_fail (search != NULL, NULL);
	_tmp0_ = data_object_get_name ((DataObject*) search);
	_tmp1_ = _tmp0_;
	self = (SavedSearchPage*) collection_page_construct (object_type, _tmp1_);
	_g_free0 (_tmp1_);
	_tmp2_ = _g_object_ref0 (search);
	_g_object_unref0 (self->priv->search);
	self->priv->search = _tmp2_;
	{
		GeeIterator* _sources_it = NULL;
		MediaCollectionRegistry* _tmp3_;
		MediaCollectionRegistry* _tmp4_;
		GeeCollection* _tmp5_;
		GeeCollection* _tmp6_;
		GeeIterator* _tmp7_;
		GeeIterator* _tmp8_;
		_tmp3_ = media_collection_registry_get_instance ();
		_tmp4_ = _tmp3_;
		_tmp5_ = media_collection_registry_get_all (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = gee_iterable_iterator ((GeeIterable*) _tmp6_);
		_tmp8_ = _tmp7_;
		_g_object_unref0 (_tmp6_);
		_media_collection_registry_unref0 (_tmp4_);
		_sources_it = _tmp8_;
		while (TRUE) {
			GeeIterator* _tmp9_;
			MediaSourceCollection* sources = NULL;
			GeeIterator* _tmp10_;
			gpointer _tmp11_;
			ViewCollection* _tmp12_;
			ViewCollection* _tmp13_;
			MediaSourceCollection* _tmp14_;
			SavedSearchManager* _tmp15_;
			SavedSearchManager* _tmp16_;
			ViewCollectionMonitor* _tmp17_;
			ViewCollectionMonitor* _tmp18_;
			_tmp9_ = _sources_it;
			if (!gee_iterator_next (_tmp9_)) {
				break;
			}
			_tmp10_ = _sources_it;
			_tmp11_ = gee_iterator_get (_tmp10_);
			sources = (MediaSourceCollection*) _tmp11_;
			_tmp12_ = page_get_view ((Page*) self);
			_tmp13_ = _tmp12_;
			_tmp14_ = sources;
			_tmp15_ = saved_search_manager_new (self, search);
			_tmp16_ = _tmp15_;
			_tmp17_ = view_collection_monitor_source_collection (_tmp13_, (SourceCollection*) _tmp14_, (ViewManager*) _tmp16_, NULL, NULL, NULL, NULL);
			_tmp18_ = _tmp17_;
			_view_collection_monitor_unref0 (_tmp18_);
			_view_manager_unref0 (_tmp16_);
			_data_collection_unref0 (_tmp13_);
			_data_collection_unref0 (sources);
		}
		_g_object_unref0 (_sources_it);
	}
	return self;
}

SavedSearchPage*
saved_search_page_new (SavedSearch* search)
{
	return saved_search_page_construct (TYPE_SAVED_SEARCH_PAGE, search);
}

static Block23Data*
block23_data_ref (Block23Data* _data23_)
{
	g_atomic_int_inc (&_data23_->_ref_count_);
	return _data23_;
}

static void
block23_data_unref (void * _userdata_)
{
	Block23Data* _data23_;
	_data23_ = (Block23Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data23_->_ref_count_)) {
		SavedSearchPage* self;
		self = _data23_->self;
		_g_object_unref0 (_data23_->delete_action);
		_g_object_unref0 (_data23_->edit_action);
		_g_object_unref0 (_data23_->rename_action);
		_g_object_unref0 (self);
		g_slice_free (Block23Data, _data23_);
	}
}

static void
___lambda94_ (Block23Data* _data23_)
{
	SavedSearchPage* self;
	GtkAction* _tmp0_;
	self = _data23_->self;
	_tmp0_ = _data23_->rename_action;
	gtk_action_activate (_tmp0_);
}

static void
____lambda94__gtk_menu_item_activate (GtkMenuItem* _sender,
                                      gpointer self)
{
	___lambda94_ (self);
}

static void
___lambda95_ (Block23Data* _data23_)
{
	SavedSearchPage* self;
	GtkAction* _tmp0_;
	self = _data23_->self;
	_tmp0_ = _data23_->edit_action;
	gtk_action_activate (_tmp0_);
}

static void
____lambda95__gtk_menu_item_activate (GtkMenuItem* _sender,
                                      gpointer self)
{
	___lambda95_ (self);
}

static void
___lambda96_ (Block23Data* _data23_)
{
	SavedSearchPage* self;
	GtkAction* _tmp0_;
	self = _data23_->self;
	_tmp0_ = _data23_->delete_action;
	gtk_action_activate (_tmp0_);
}

static void
____lambda96__gtk_menu_item_activate (GtkMenuItem* _sender,
                                      gpointer self)
{
	___lambda96_ (self);
}

static GtkMenu*
saved_search_page_real_get_page_sidebar_menu (Page* base)
{
	SavedSearchPage * self;
	GtkMenu* _tmp0_;
	GtkMenu* _tmp18_;
	GtkMenu* _tmp19_;
	GtkMenu* result;
	self = (SavedSearchPage*) base;
	_tmp0_ = self->priv->page_sidebar_menu;
	if (_tmp0_ == NULL) {
		Block23Data* _data23_;
		GtkMenu* _tmp1_;
		GtkMenuItem* rename_menu_item = NULL;
		GtkMenuItem* _tmp2_;
		GtkAction* _tmp3_;
		GtkMenuItem* _tmp4_;
		GtkMenuItem* edit_menu_item = NULL;
		GtkMenuItem* _tmp5_;
		GtkAction* _tmp6_;
		GtkMenuItem* _tmp7_;
		GtkMenuItem* delete_menu_item = NULL;
		GtkMenuItem* _tmp8_;
		GtkAction* _tmp9_;
		GtkMenuItem* _tmp10_;
		GtkMenu* _tmp11_;
		GtkMenuItem* _tmp12_;
		GtkMenu* _tmp13_;
		GtkMenuItem* _tmp14_;
		GtkMenu* _tmp15_;
		GtkMenuItem* _tmp16_;
		GtkMenu* _tmp17_;
		_data23_ = g_slice_new0 (Block23Data);
		_data23_->_ref_count_ = 1;
		_data23_->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_SEARCH_MENU);
		g_object_ref_sink (_tmp2_);
		rename_menu_item = _tmp2_;
		_tmp3_ = page_get_action ((Page*) self, "RenameSearch");
		_data23_->rename_action = _tmp3_;
		_tmp4_ = rename_menu_item;
		g_signal_connect_data (_tmp4_, "activate", (GCallback) ____lambda94__gtk_menu_item_activate, block23_data_ref (_data23_), (GClosureNotify) block23_data_unref, 0);
		_tmp5_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic (RESOURCES_EDIT_SEARCH_MENU);
		g_object_ref_sink (_tmp5_);
		edit_menu_item = _tmp5_;
		_tmp6_ = page_get_action ((Page*) self, "EditSearch");
		_data23_->edit_action = _tmp6_;
		_tmp7_ = edit_menu_item;
		g_signal_connect_data (_tmp7_, "activate", (GCallback) ____lambda95__gtk_menu_item_activate, block23_data_ref (_data23_), (GClosureNotify) block23_data_unref, 0);
		_tmp8_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic (RESOURCES_DELETE_SEARCH_MENU);
		g_object_ref_sink (_tmp8_);
		delete_menu_item = _tmp8_;
		_tmp9_ = page_get_action ((Page*) self, "DeleteSearch");
		_data23_->delete_action = _tmp9_;
		_tmp10_ = delete_menu_item;
		g_signal_connect_data (_tmp10_, "activate", (GCallback) ____lambda96__gtk_menu_item_activate, block23_data_ref (_data23_), (GClosureNotify) block23_data_unref, 0);
		_tmp11_ = self->priv->page_sidebar_menu;
		_tmp12_ = rename_menu_item;
		gtk_container_add ((GtkContainer*) _tmp11_, (GtkWidget*) _tmp12_);
		_tmp13_ = self->priv->page_sidebar_menu;
		_tmp14_ = edit_menu_item;
		gtk_container_add ((GtkContainer*) _tmp13_, (GtkWidget*) _tmp14_);
		_tmp15_ = self->priv->page_sidebar_menu;
		_tmp16_ = delete_menu_item;
		gtk_container_add ((GtkContainer*) _tmp15_, (GtkWidget*) _tmp16_);
		_tmp17_ = self->priv->page_sidebar_menu;
		gtk_widget_show_all ((GtkWidget*) _tmp17_);
		_g_object_unref0 (delete_menu_item);
		_g_object_unref0 (edit_menu_item);
		_g_object_unref0 (rename_menu_item);
		block23_data_unref (_data23_);
		_data23_ = NULL;
	}
	_tmp18_ = self->priv->page_sidebar_menu;
	_tmp19_ = _g_object_ref0 (_tmp18_);
	result = _tmp19_;
	return result;
}

static void
_saved_search_page_on_rename_search_gcallback (GtkAction* action,
                                               gpointer self)
{
	saved_search_page_on_rename_search ((SavedSearchPage*) self);
}

static void
_vala_array_add212 (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
_saved_search_page_on_edit_search_gcallback (GtkAction* action,
                                             gpointer self)
{
	saved_search_page_on_edit_search ((SavedSearchPage*) self);
}

static void
_vala_array_add213 (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
_saved_search_page_on_delete_search_gcallback (GtkAction* action,
                                               gpointer self)
{
	saved_search_page_on_delete_search ((SavedSearchPage*) self);
}

static void
_vala_array_add214 (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*
saved_search_page_real_init_collect_action_entries (Page* base,
                                                    gint* result_length1)
{
	SavedSearchPage * self;
	GtkActionEntry* actions = NULL;
	gint _tmp0_ = 0;
	GtkActionEntry* _tmp1_;
	gint actions_length1;
	gint _actions_size_;
	GtkActionEntry rename_search = {0};
	GtkActionEntry _tmp2_ = {0};
	GtkActionEntry _tmp3_;
	GtkActionEntry edit_search = {0};
	GtkActionEntry _tmp4_ = {0};
	GtkActionEntry _tmp5_;
	GtkActionEntry delete_search = {0};
	GtkActionEntry _tmp6_ = {0};
	GtkActionEntry _tmp7_;
	GtkActionEntry* _tmp8_;
	gint _tmp8__length1;
	GtkActionEntry* result;
	self = (SavedSearchPage*) base;
	_tmp1_ = PAGE_CLASS (saved_search_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 = "RenameSearch";
	_tmp2_.stock_id = NULL;
	_tmp2_.label = TRANSLATABLE;
	_tmp2_.accelerator = NULL;
	_tmp2_.tooltip = NULL;
	_tmp2_.callback = (GCallback) _saved_search_page_on_rename_search_gcallback;
	rename_search = _tmp2_;
	_tmp3_ = rename_search;
	_vala_array_add212 (&actions, &actions_length1, &_actions_size_, &_tmp3_);
	_tmp4_.name = "EditSearch";
	_tmp4_.stock_id = NULL;
	_tmp4_.label = TRANSLATABLE;
	_tmp4_.accelerator = NULL;
	_tmp4_.tooltip = NULL;
	_tmp4_.callback = (GCallback) _saved_search_page_on_edit_search_gcallback;
	edit_search = _tmp4_;
	_tmp5_ = edit_search;
	_vala_array_add213 (&actions, &actions_length1, &_actions_size_, &_tmp5_);
	_tmp6_.name = "DeleteSearch";
	_tmp6_.stock_id = NULL;
	_tmp6_.label = TRANSLATABLE;
	_tmp6_.accelerator = NULL;
	_tmp6_.tooltip = NULL;
	_tmp6_.callback = (GCallback) _saved_search_page_on_delete_search_gcallback;
	delete_search = _tmp6_;
	_tmp7_ = delete_search;
	_vala_array_add214 (&actions, &actions_length1, &_actions_size_, &_tmp7_);
	_tmp8_ = actions;
	_tmp8__length1 = actions_length1;
	if (result_length1) {
		*result_length1 = _tmp8__length1;
	}
	result = _tmp8_;
	return result;
}

static void
saved_search_page_on_delete_search (SavedSearchPage* self)
{
	SavedSearch* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->search;
	if (dialogs_confirm_delete_saved_search (_tmp0_)) {
		CommandManager* _tmp1_;
		CommandManager* _tmp2_;
		SavedSearch* _tmp3_;
		DeleteSavedSearchCommand* _tmp4_;
		DeleteSavedSearchCommand* _tmp5_;
		_tmp1_ = app_window_get_command_manager ();
		_tmp2_ = _tmp1_;
		_tmp3_ = self->priv->search;
		_tmp4_ = delete_saved_search_command_new (_tmp3_);
		_tmp5_ = _tmp4_;
		command_manager_execute (_tmp2_, (Command*) _tmp5_);
		_g_object_unref0 (_tmp5_);
		_command_manager_unref0 (_tmp2_);
	}
}

static void
saved_search_page_on_rename_search (SavedSearchPage* self)
{
	LibraryWindow* _tmp0_;
	LibraryWindow* _tmp1_;
	SavedSearch* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = library_window_get_app ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->search;
	library_window_rename_search_in_sidebar (_tmp1_, _tmp2_);
	_g_object_unref0 (_tmp1_);
}

static void
saved_search_page_on_edit_search (SavedSearchPage* self)
{
	SavedSearchDialog* ssd = NULL;
	SavedSearch* _tmp0_;
	SavedSearchDialog* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->search;
	_tmp1_ = saved_search_dialog_new_edit_existing (_tmp0_);
	ssd = _tmp1_;
	saved_search_dialog_show (ssd);
	_g_object_unref0 (ssd);
}

static void
saved_search_page_real_update_actions (Page* base,
                                       gint selected_count,
                                       gint count)
{
	SavedSearchPage * self;
	self = (SavedSearchPage*) base;
	collection_page_set_action_details ((CollectionPage*) self, "RenameSearch", RESOURCES_RENAME_SEARCH_MENU, NULL, TRUE);
	collection_page_set_action_details ((CollectionPage*) self, "EditSearch", RESOURCES_EDIT_SEARCH_MENU, NULL, TRUE);
	collection_page_set_action_details ((CollectionPage*) self, "DeleteSearch", RESOURCES_DELETE_SEARCH_MENU, NULL, TRUE);
	PAGE_CLASS (saved_search_page_parent_class)->update_actions ((Page*) G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_COLLECTION_PAGE, CollectionPage), selected_count, count);
}

static void
saved_search_page_class_init (SavedSearchPageClass * klass,
                              gpointer klass_data)
{
	saved_search_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SavedSearchPage_private_offset);
	((PageClass *) klass)->get_page_sidebar_menu = (GtkMenu* (*) (Page*)) saved_search_page_real_get_page_sidebar_menu;
	((PageClass *) klass)->init_collect_action_entries = (GtkActionEntry* (*) (Page*, gint*)) saved_search_page_real_init_collect_action_entries;
	((PageClass *) klass)->update_actions = (void (*) (Page*, gint, gint)) saved_search_page_real_update_actions;
	G_OBJECT_CLASS (klass)->finalize = saved_search_page_finalize;
}

static void
saved_search_page_instance_init (SavedSearchPage * self,
                                 gpointer klass)
{
	self->priv = saved_search_page_get_instance_private (self);
}

static void
saved_search_page_finalize (GObject * obj)
{
	SavedSearchPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SAVED_SEARCH_PAGE, SavedSearchPage);
	_g_object_unref0 (self->priv->search);
	_g_object_unref0 (self->priv->page_sidebar_menu);
	G_OBJECT_CLASS (saved_search_page_parent_class)->finalize (obj);
}

static GType
saved_search_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SavedSearchPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) saved_search_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SavedSearchPage), 0, (GInstanceInitFunc) saved_search_page_instance_init, NULL };
	GType saved_search_page_type_id;
	saved_search_page_type_id = g_type_register_static (TYPE_COLLECTION_PAGE, "SavedSearchPage", &g_define_type_info, 0);
	SavedSearchPage_private_offset = g_type_add_instance_private (saved_search_page_type_id, sizeof (SavedSearchPagePrivate));
	return saved_search_page_type_id;
}

GType
saved_search_page_get_type (void)
{
	static volatile gsize saved_search_page_type_id__once = 0;
	if (g_once_init_enter (&saved_search_page_type_id__once)) {
		GType saved_search_page_type_id;
		saved_search_page_type_id = saved_search_page_get_type_once ();
		g_once_init_leave (&saved_search_page_type_id__once, saved_search_page_type_id);
	}
	return saved_search_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;
}

