/* FlaggedPage.c generated by valac 0.56.19, the Vala compiler
 * generated from FlaggedPage.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 <glib-object.h>
#include <gee.h>
#include <glib.h>
#include <string.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 FLAGGED_PAGE_TYPE_FLAGGED_SEARCH_VIEW_FILTER (flagged_page_flagged_search_view_filter_get_type ())
#define FLAGGED_PAGE_FLAGGED_SEARCH_VIEW_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FLAGGED_PAGE_TYPE_FLAGGED_SEARCH_VIEW_FILTER, FlaggedPageFlaggedSearchViewFilter))
#define FLAGGED_PAGE_FLAGGED_SEARCH_VIEW_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FLAGGED_PAGE_TYPE_FLAGGED_SEARCH_VIEW_FILTER, FlaggedPageFlaggedSearchViewFilterClass))
#define FLAGGED_PAGE_IS_FLAGGED_SEARCH_VIEW_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FLAGGED_PAGE_TYPE_FLAGGED_SEARCH_VIEW_FILTER))
#define FLAGGED_PAGE_IS_FLAGGED_SEARCH_VIEW_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FLAGGED_PAGE_TYPE_FLAGGED_SEARCH_VIEW_FILTER))
#define FLAGGED_PAGE_FLAGGED_SEARCH_VIEW_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FLAGGED_PAGE_TYPE_FLAGGED_SEARCH_VIEW_FILTER, FlaggedPageFlaggedSearchViewFilterClass))

typedef struct _FlaggedPageFlaggedSearchViewFilter FlaggedPageFlaggedSearchViewFilter;
typedef struct _FlaggedPageFlaggedSearchViewFilterClass FlaggedPageFlaggedSearchViewFilterClass;
enum  {
	FLAGGED_PAGE_0_PROPERTY,
	FLAGGED_PAGE_NUM_PROPERTIES
};
static GParamSpec* flagged_page_properties[FLAGGED_PAGE_NUM_PROPERTIES];
#define _view_manager_unref0(var) ((var == NULL) ? NULL : (var = (view_manager_unref (var), NULL)))
#define _alteration_unref0(var) ((var == NULL) ? NULL : (var = (alteration_unref (var), NULL)))
#define _view_filter_unref0(var) ((var == NULL) ? NULL : (var = (view_filter_unref (var), NULL)))

#define FLAGGED_PAGE_TYPE_FLAGGED_VIEW_MANAGER (flagged_page_flagged_view_manager_get_type ())
#define FLAGGED_PAGE_FLAGGED_VIEW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FLAGGED_PAGE_TYPE_FLAGGED_VIEW_MANAGER, FlaggedPageFlaggedViewManager))
#define FLAGGED_PAGE_FLAGGED_VIEW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FLAGGED_PAGE_TYPE_FLAGGED_VIEW_MANAGER, FlaggedPageFlaggedViewManagerClass))
#define FLAGGED_PAGE_IS_FLAGGED_VIEW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FLAGGED_PAGE_TYPE_FLAGGED_VIEW_MANAGER))
#define FLAGGED_PAGE_IS_FLAGGED_VIEW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FLAGGED_PAGE_TYPE_FLAGGED_VIEW_MANAGER))
#define FLAGGED_PAGE_FLAGGED_VIEW_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FLAGGED_PAGE_TYPE_FLAGGED_VIEW_MANAGER, FlaggedPageFlaggedViewManagerClass))

typedef struct _FlaggedPageFlaggedViewManager FlaggedPageFlaggedViewManager;
typedef struct _FlaggedPageFlaggedViewManagerClass FlaggedPageFlaggedViewManagerClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (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 _data_collection_unref0(var) ((var == NULL) ? NULL : (var = (data_collection_unref (var), NULL)))
typedef struct _FlaggedPageFlaggedViewManagerPrivate FlaggedPageFlaggedViewManagerPrivate;
typedef struct _FlaggedPageFlaggedSearchViewFilterPrivate FlaggedPageFlaggedSearchViewFilterPrivate;

struct _FlaggedPagePrivate {
	ViewManager* view_manager;
	Alteration* prereq;
	FlaggedPageFlaggedSearchViewFilter* search_filter;
};

struct _FlaggedPageFlaggedViewManager {
	CollectionViewManager parent_instance;
	FlaggedPageFlaggedViewManagerPrivate * priv;
};

struct _FlaggedPageFlaggedViewManagerClass {
	CollectionViewManagerClass parent_class;
};

struct _FlaggedPageFlaggedSearchViewFilter {
	CollectionPageCollectionSearchViewFilter parent_instance;
	FlaggedPageFlaggedSearchViewFilterPrivate * priv;
};

struct _FlaggedPageFlaggedSearchViewFilterClass {
	CollectionPageCollectionSearchViewFilterClass parent_class;
};

static gint FlaggedPage_private_offset;
static gpointer flagged_page_parent_class = NULL;
static gpointer flagged_page_flagged_view_manager_parent_class = NULL;
static gpointer flagged_page_flagged_search_view_filter_parent_class = NULL;

static GType flagged_page_flagged_search_view_filter_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static FlaggedPageFlaggedSearchViewFilter* flagged_page_flagged_search_view_filter_new (void);
static FlaggedPageFlaggedSearchViewFilter* flagged_page_flagged_search_view_filter_construct (GType object_type);
static FlaggedPageFlaggedViewManager* flagged_page_flagged_view_manager_new (FlaggedPage* owner);
static FlaggedPageFlaggedViewManager* flagged_page_flagged_view_manager_construct (GType object_type,
                                                                            FlaggedPage* owner);
static GType flagged_page_flagged_view_manager_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static SearchViewFilter* flagged_page_real_get_search_view_filter (CheckerboardPage* base);
static gboolean flagged_page_flagged_view_manager_real_include_in_view (ViewManager* base,
                                                                 DataSource* source);
static GType flagged_page_flagged_view_manager_get_type_once (void);
static guint flagged_page_flagged_search_view_filter_real_get_criteria (SearchViewFilter* base);
static GType flagged_page_flagged_search_view_filter_get_type_once (void);
static void flagged_page_finalize (GObject * obj);
static GType flagged_page_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
flagged_page_get_instance_private (FlaggedPage* self)
{
	return G_STRUCT_MEMBER_P (self, FlaggedPage_private_offset);
}

FlaggedPage*
flagged_page_construct (GType object_type)
{
	FlaggedPage * self = NULL;
	FlaggedPageFlaggedViewManager* _tmp0_;
	self = (FlaggedPage*) collection_page_construct (object_type, FLAGGED_PAGE_NAME);
	_tmp0_ = flagged_page_flagged_view_manager_new (self);
	_view_manager_unref0 (self->priv->view_manager);
	self->priv->view_manager = (ViewManager*) _tmp0_;
	{
		GeeIterator* _sources_it = NULL;
		MediaCollectionRegistry* _tmp1_;
		MediaCollectionRegistry* _tmp2_;
		GeeCollection* _tmp3_;
		GeeCollection* _tmp4_;
		GeeIterator* _tmp5_;
		GeeIterator* _tmp6_;
		_tmp1_ = media_collection_registry_get_instance ();
		_tmp2_ = _tmp1_;
		_tmp3_ = media_collection_registry_get_all (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_);
		_tmp6_ = _tmp5_;
		_g_object_unref0 (_tmp4_);
		_media_collection_registry_unref0 (_tmp2_);
		_sources_it = _tmp6_;
		while (TRUE) {
			GeeIterator* _tmp7_;
			MediaSourceCollection* sources = NULL;
			GeeIterator* _tmp8_;
			gpointer _tmp9_;
			ViewCollection* _tmp10_;
			ViewCollection* _tmp11_;
			MediaSourceCollection* _tmp12_;
			ViewManager* _tmp13_;
			Alteration* _tmp14_;
			ViewCollectionMonitor* _tmp15_;
			ViewCollectionMonitor* _tmp16_;
			_tmp7_ = _sources_it;
			if (!gee_iterator_next (_tmp7_)) {
				break;
			}
			_tmp8_ = _sources_it;
			_tmp9_ = gee_iterator_get (_tmp8_);
			sources = (MediaSourceCollection*) _tmp9_;
			_tmp10_ = page_get_view ((Page*) self);
			_tmp11_ = _tmp10_;
			_tmp12_ = sources;
			_tmp13_ = self->priv->view_manager;
			_tmp14_ = self->priv->prereq;
			_tmp15_ = view_collection_monitor_source_collection (_tmp11_, (SourceCollection*) _tmp12_, _tmp13_, _tmp14_, NULL, NULL, NULL);
			_tmp16_ = _tmp15_;
			_view_collection_monitor_unref0 (_tmp16_);
			_data_collection_unref0 (_tmp11_);
			_data_collection_unref0 (sources);
		}
		_g_object_unref0 (_sources_it);
	}
	return self;
}

FlaggedPage*
flagged_page_new (void)
{
	return flagged_page_construct (TYPE_FLAGGED_PAGE);
}

static gpointer
_view_filter_ref0 (gpointer self)
{
	return self ? view_filter_ref (self) : NULL;
}

static SearchViewFilter*
flagged_page_real_get_search_view_filter (CheckerboardPage* base)
{
	FlaggedPage * self;
	FlaggedPageFlaggedSearchViewFilter* _tmp0_;
	SearchViewFilter* _tmp1_;
	SearchViewFilter* result;
	self = (FlaggedPage*) base;
	_tmp0_ = self->priv->search_filter;
	_tmp1_ = _view_filter_ref0 ((SearchViewFilter*) _tmp0_);
	result = _tmp1_;
	return result;
}

static FlaggedPageFlaggedViewManager*
flagged_page_flagged_view_manager_construct (GType object_type,
                                             FlaggedPage* owner)
{
	FlaggedPageFlaggedViewManager* self = NULL;
	g_return_val_if_fail (owner != NULL, NULL);
	self = (FlaggedPageFlaggedViewManager*) collection_view_manager_construct (object_type, (CollectionPage*) owner);
	return self;
}

static FlaggedPageFlaggedViewManager*
flagged_page_flagged_view_manager_new (FlaggedPage* owner)
{
	return flagged_page_flagged_view_manager_construct (FLAGGED_PAGE_TYPE_FLAGGED_VIEW_MANAGER, owner);
}

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

static gboolean
flagged_page_flagged_view_manager_real_include_in_view (ViewManager* base,
                                                        DataSource* source)
{
	FlaggedPageFlaggedViewManager * self;
	Flaggable* flaggable = NULL;
	Flaggable* _tmp0_;
	gboolean _tmp1_ = FALSE;
	Flaggable* _tmp2_;
	gboolean result;
	self = (FlaggedPageFlaggedViewManager*) base;
	g_return_val_if_fail (source != NULL, FALSE);
	_tmp0_ = _g_object_ref0 (IS_FLAGGABLE (source) ? ((Flaggable*) source) : NULL);
	flaggable = _tmp0_;
	_tmp2_ = flaggable;
	if (_tmp2_ != NULL) {
		Flaggable* _tmp3_;
		_tmp3_ = flaggable;
		_tmp1_ = flaggable_is_flagged (_tmp3_);
	} else {
		_tmp1_ = FALSE;
	}
	result = _tmp1_;
	_g_object_unref0 (flaggable);
	return result;
}

static void
flagged_page_flagged_view_manager_class_init (FlaggedPageFlaggedViewManagerClass * klass,
                                              gpointer klass_data)
{
	flagged_page_flagged_view_manager_parent_class = g_type_class_peek_parent (klass);
	((ViewManagerClass *) klass)->include_in_view = (gboolean (*) (ViewManager*, DataSource*)) flagged_page_flagged_view_manager_real_include_in_view;
}

static void
flagged_page_flagged_view_manager_instance_init (FlaggedPageFlaggedViewManager * self,
                                                 gpointer klass)
{
}

static GType
flagged_page_flagged_view_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FlaggedPageFlaggedViewManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) flagged_page_flagged_view_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FlaggedPageFlaggedViewManager), 0, (GInstanceInitFunc) flagged_page_flagged_view_manager_instance_init, NULL };
	GType flagged_page_flagged_view_manager_type_id;
	flagged_page_flagged_view_manager_type_id = g_type_register_static (TYPE_COLLECTION_VIEW_MANAGER, "FlaggedPageFlaggedViewManager", &g_define_type_info, 0);
	return flagged_page_flagged_view_manager_type_id;
}

static GType
flagged_page_flagged_view_manager_get_type (void)
{
	static volatile gsize flagged_page_flagged_view_manager_type_id__once = 0;
	if (g_once_init_enter (&flagged_page_flagged_view_manager_type_id__once)) {
		GType flagged_page_flagged_view_manager_type_id;
		flagged_page_flagged_view_manager_type_id = flagged_page_flagged_view_manager_get_type_once ();
		g_once_init_leave (&flagged_page_flagged_view_manager_type_id__once, flagged_page_flagged_view_manager_type_id);
	}
	return flagged_page_flagged_view_manager_type_id__once;
}

static guint
flagged_page_flagged_search_view_filter_real_get_criteria (SearchViewFilter* base)
{
	FlaggedPageFlaggedSearchViewFilter * self;
	guint result;
	self = (FlaggedPageFlaggedSearchViewFilter*) base;
	result = (guint) (SEARCH_FILTER_CRITERIA_TEXT | SEARCH_FILTER_CRITERIA_MEDIA);
	return result;
}

static FlaggedPageFlaggedSearchViewFilter*
flagged_page_flagged_search_view_filter_construct (GType object_type)
{
	FlaggedPageFlaggedSearchViewFilter* self = NULL;
	self = (FlaggedPageFlaggedSearchViewFilter*) collection_page_collection_search_view_filter_construct (object_type);
	return self;
}

static FlaggedPageFlaggedSearchViewFilter*
flagged_page_flagged_search_view_filter_new (void)
{
	return flagged_page_flagged_search_view_filter_construct (FLAGGED_PAGE_TYPE_FLAGGED_SEARCH_VIEW_FILTER);
}

static void
flagged_page_flagged_search_view_filter_class_init (FlaggedPageFlaggedSearchViewFilterClass * klass,
                                                    gpointer klass_data)
{
	flagged_page_flagged_search_view_filter_parent_class = g_type_class_peek_parent (klass);
	((SearchViewFilterClass *) klass)->get_criteria = (guint (*) (SearchViewFilter*)) flagged_page_flagged_search_view_filter_real_get_criteria;
}

static void
flagged_page_flagged_search_view_filter_instance_init (FlaggedPageFlaggedSearchViewFilter * self,
                                                       gpointer klass)
{
}

static GType
flagged_page_flagged_search_view_filter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FlaggedPageFlaggedSearchViewFilterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) flagged_page_flagged_search_view_filter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FlaggedPageFlaggedSearchViewFilter), 0, (GInstanceInitFunc) flagged_page_flagged_search_view_filter_instance_init, NULL };
	GType flagged_page_flagged_search_view_filter_type_id;
	flagged_page_flagged_search_view_filter_type_id = g_type_register_static (COLLECTION_PAGE_TYPE_COLLECTION_SEARCH_VIEW_FILTER, "FlaggedPageFlaggedSearchViewFilter", &g_define_type_info, 0);
	return flagged_page_flagged_search_view_filter_type_id;
}

static GType
flagged_page_flagged_search_view_filter_get_type (void)
{
	static volatile gsize flagged_page_flagged_search_view_filter_type_id__once = 0;
	if (g_once_init_enter (&flagged_page_flagged_search_view_filter_type_id__once)) {
		GType flagged_page_flagged_search_view_filter_type_id;
		flagged_page_flagged_search_view_filter_type_id = flagged_page_flagged_search_view_filter_get_type_once ();
		g_once_init_leave (&flagged_page_flagged_search_view_filter_type_id__once, flagged_page_flagged_search_view_filter_type_id);
	}
	return flagged_page_flagged_search_view_filter_type_id__once;
}

static void
flagged_page_class_init (FlaggedPageClass * klass,
                         gpointer klass_data)
{
	flagged_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FlaggedPage_private_offset);
	((CheckerboardPageClass *) klass)->get_search_view_filter = (SearchViewFilter* (*) (CheckerboardPage*)) flagged_page_real_get_search_view_filter;
	G_OBJECT_CLASS (klass)->finalize = flagged_page_finalize;
}

static void
flagged_page_instance_init (FlaggedPage * self,
                            gpointer klass)
{
	Alteration* _tmp0_;
	FlaggedPageFlaggedSearchViewFilter* _tmp1_;
	self->priv = flagged_page_get_instance_private (self);
	_tmp0_ = alteration_new ("metadata", "flagged");
	self->priv->prereq = _tmp0_;
	_tmp1_ = flagged_page_flagged_search_view_filter_new ();
	self->priv->search_filter = _tmp1_;
}

static void
flagged_page_finalize (GObject * obj)
{
	FlaggedPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FLAGGED_PAGE, FlaggedPage);
	_view_manager_unref0 (self->priv->view_manager);
	_alteration_unref0 (self->priv->prereq);
	_view_filter_unref0 (self->priv->search_filter);
	G_OBJECT_CLASS (flagged_page_parent_class)->finalize (obj);
}

static GType
flagged_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FlaggedPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) flagged_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FlaggedPage), 0, (GInstanceInitFunc) flagged_page_instance_init, NULL };
	GType flagged_page_type_id;
	flagged_page_type_id = g_type_register_static (TYPE_COLLECTION_PAGE, "FlaggedPage", &g_define_type_info, 0);
	FlaggedPage_private_offset = g_type_add_instance_private (flagged_page_type_id, sizeof (FlaggedPagePrivate));
	return flagged_page_type_id;
}

GType
flagged_page_get_type (void)
{
	static volatile gsize flagged_page_type_id__once = 0;
	if (g_once_init_enter (&flagged_page_type_id__once)) {
		GType flagged_page_type_id;
		flagged_page_type_id = flagged_page_get_type_once ();
		g_once_init_leave (&flagged_page_type_id__once, flagged_page_type_id);
	}
	return flagged_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;
}

