/* DirectView.c generated by valac 0.56.19, the Vala compiler
 * generated from DirectView.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
*/

#include "io.elementary.photos.h"
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.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  {
	DIRECT_VIEW_0_PROPERTY,
	DIRECT_VIEW_NUM_PROPERTIES
};
static GParamSpec* direct_view_properties[DIRECT_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_DIRECT_VIEW_COLLECTION (direct_view_collection_get_type ())
#define DIRECT_VIEW_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DIRECT_VIEW_COLLECTION, DirectViewCollection))
#define DIRECT_VIEW_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DIRECT_VIEW_COLLECTION, DirectViewCollectionClass))
#define IS_DIRECT_VIEW_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DIRECT_VIEW_COLLECTION))
#define IS_DIRECT_VIEW_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DIRECT_VIEW_COLLECTION))
#define DIRECT_VIEW_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DIRECT_VIEW_COLLECTION, DirectViewCollectionClass))

typedef struct _DirectViewCollection DirectViewCollection;
typedef struct _DirectViewCollectionClass DirectViewCollectionClass;
typedef struct _DirectViewCollectionPrivate DirectViewCollectionPrivate;

#define DIRECT_VIEW_COLLECTION_TYPE_DIRECT_VIEW_MANAGER (direct_view_collection_direct_view_manager_get_type ())
#define DIRECT_VIEW_COLLECTION_DIRECT_VIEW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIRECT_VIEW_COLLECTION_TYPE_DIRECT_VIEW_MANAGER, DirectViewCollectionDirectViewManager))
#define DIRECT_VIEW_COLLECTION_DIRECT_VIEW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIRECT_VIEW_COLLECTION_TYPE_DIRECT_VIEW_MANAGER, DirectViewCollectionDirectViewManagerClass))
#define DIRECT_VIEW_COLLECTION_IS_DIRECT_VIEW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIRECT_VIEW_COLLECTION_TYPE_DIRECT_VIEW_MANAGER))
#define DIRECT_VIEW_COLLECTION_IS_DIRECT_VIEW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIRECT_VIEW_COLLECTION_TYPE_DIRECT_VIEW_MANAGER))
#define DIRECT_VIEW_COLLECTION_DIRECT_VIEW_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIRECT_VIEW_COLLECTION_TYPE_DIRECT_VIEW_MANAGER, DirectViewCollectionDirectViewManagerClass))

typedef struct _DirectViewCollectionDirectViewManager DirectViewCollectionDirectViewManager;
typedef struct _DirectViewCollectionDirectViewManagerClass DirectViewCollectionDirectViewManagerClass;
#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 _DirectViewCollectionDirectViewManagerPrivate DirectViewCollectionDirectViewManagerPrivate;

struct _DirectViewPrivate {
	GFile* file;
	gchar* collate_key;
};

struct _DirectViewCollection {
	ViewCollection parent_instance;
	DirectViewCollectionPrivate * priv;
};

struct _DirectViewCollectionClass {
	ViewCollectionClass parent_class;
};

struct _DirectViewCollectionDirectViewManager {
	ViewManager parent_instance;
	DirectViewCollectionDirectViewManagerPrivate * priv;
};

struct _DirectViewCollectionDirectViewManagerClass {
	ViewManagerClass parent_class;
};

static gint DirectView_private_offset;
static gpointer direct_view_parent_class = NULL;
static gpointer direct_view_collection_parent_class = NULL;
static gpointer direct_view_collection_direct_view_manager_parent_class = NULL;

static void direct_view_finalize (GObject * obj);
static GType direct_view_get_type_once (void);
VALA_EXTERN GType direct_view_collection_get_type (void) G_GNUC_CONST ;
VALA_EXTERN DirectViewCollection* direct_view_collection_new (void);
VALA_EXTERN DirectViewCollection* direct_view_collection_construct (GType object_type);
static gint64 direct_view_collection_filename_comparator (void* a,
                                                   void* b);
static gint64 _direct_view_collection_filename_comparator_comparator (void* a,
                                                               void* b,
                                                               gpointer self);
static DirectViewCollectionDirectViewManager* direct_view_collection_direct_view_manager_new (void);
static DirectViewCollectionDirectViewManager* direct_view_collection_direct_view_manager_construct (GType object_type);
static GType direct_view_collection_direct_view_manager_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static DataView* direct_view_collection_direct_view_manager_real_create_view (ViewManager* base,
                                                                       DataSource* source);
static GType direct_view_collection_direct_view_manager_get_type_once (void);
static GType direct_view_collection_get_type_once (void);

static inline gpointer
direct_view_get_instance_private (DirectView* self)
{
	return G_STRUCT_MEMBER_P (self, DirectView_private_offset);
}

DirectView*
direct_view_construct (GType object_type,
                       DirectPhoto* source)
{
	DirectView * self = NULL;
	GFile* _tmp0_;
	g_return_val_if_fail (source != NULL, NULL);
	self = (DirectView*) data_view_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (source, TYPE_DATA_SOURCE, DataSource));
	_tmp0_ = media_source_get_file ((MediaSource*) G_TYPE_CHECK_INSTANCE_CAST (source, TYPE_PHOTO, Photo));
	_g_object_unref0 (self->priv->file);
	self->priv->file = _tmp0_;
	return self;
}

DirectView*
direct_view_new (DirectPhoto* source)
{
	return direct_view_construct (TYPE_DIRECT_VIEW, source);
}

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

GFile*
direct_view_get_file (DirectView* self)
{
	GFile* _tmp0_;
	GFile* _tmp1_;
	GFile* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->file;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

gchar*
direct_view_get_collate_key (DirectView* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->collate_key;
	if (_tmp0_ == NULL) {
		GFile* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp1_ = self->priv->file;
		_tmp2_ = g_file_get_basename (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = g_utf8_collate_key_for_filename (_tmp3_, (gssize) -1);
		_g_free0 (self->priv->collate_key);
		self->priv->collate_key = _tmp4_;
		_g_free0 (_tmp3_);
	}
	_tmp5_ = self->priv->collate_key;
	_tmp6_ = g_strdup (_tmp5_);
	result = _tmp6_;
	return result;
}

static void
direct_view_class_init (DirectViewClass * klass,
                        gpointer klass_data)
{
	direct_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DirectView_private_offset);
	G_OBJECT_CLASS (klass)->finalize = direct_view_finalize;
}

static void
direct_view_instance_init (DirectView * self,
                           gpointer klass)
{
	self->priv = direct_view_get_instance_private (self);
	self->priv->collate_key = NULL;
}

static void
direct_view_finalize (GObject * obj)
{
	DirectView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DIRECT_VIEW, DirectView);
	_g_object_unref0 (self->priv->file);
	_g_free0 (self->priv->collate_key);
	G_OBJECT_CLASS (direct_view_parent_class)->finalize (obj);
}

static GType
direct_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DirectViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) direct_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DirectView), 0, (GInstanceInitFunc) direct_view_instance_init, NULL };
	GType direct_view_type_id;
	direct_view_type_id = g_type_register_static (TYPE_DATA_VIEW, "DirectView", &g_define_type_info, 0);
	DirectView_private_offset = g_type_add_instance_private (direct_view_type_id, sizeof (DirectViewPrivate));
	return direct_view_type_id;
}

GType
direct_view_get_type (void)
{
	static volatile gsize direct_view_type_id__once = 0;
	if (g_once_init_enter (&direct_view_type_id__once)) {
		GType direct_view_type_id;
		direct_view_type_id = direct_view_get_type_once ();
		g_once_init_leave (&direct_view_type_id__once, direct_view_type_id);
	}
	return direct_view_type_id__once;
}

static gint64
_direct_view_collection_filename_comparator_comparator (void* a,
                                                        void* b,
                                                        gpointer self)
{
	gint64 result;
	result = direct_view_collection_filename_comparator (a, b);
	return result;
}

DirectViewCollection*
direct_view_collection_construct (GType object_type)
{
	DirectViewCollection* self = NULL;
	DirectPhotoSourceCollection* _tmp0_;
	DirectViewCollectionDirectViewManager* _tmp1_;
	DirectViewCollectionDirectViewManager* _tmp2_;
	ViewCollectionMonitor* _tmp3_;
	ViewCollectionMonitor* _tmp4_;
	self = (DirectViewCollection*) view_collection_construct (object_type, "DirectViewCollection");
	data_collection_set_comparator ((DataCollection*) self, _direct_view_collection_filename_comparator_comparator, NULL, NULL, NULL);
	_tmp0_ = direct_photo_global;
	_tmp1_ = direct_view_collection_direct_view_manager_new ();
	_tmp2_ = _tmp1_;
	_tmp3_ = view_collection_monitor_source_collection ((ViewCollection*) self, (SourceCollection*) _tmp0_, (ViewManager*) _tmp2_, NULL, NULL, NULL, NULL);
	_tmp4_ = _tmp3_;
	_view_collection_monitor_unref0 (_tmp4_);
	_view_manager_unref0 (_tmp2_);
	return self;
}

DirectViewCollection*
direct_view_collection_new (void)
{
	return direct_view_collection_construct (TYPE_DIRECT_VIEW_COLLECTION);
}

static gint64
direct_view_collection_filename_comparator (void* a,
                                            void* b)
{
	DirectView* aview = NULL;
	DirectView* bview = NULL;
	GCompareFunc _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gint64 _tmp5_;
	gint64 result;
	aview = (DirectView*) a;
	bview = (DirectView*) b;
	_tmp0_ = ((GCompareFunc) g_strcmp0);
	_tmp1_ = direct_view_get_collate_key (aview);
	_tmp2_ = _tmp1_;
	_tmp3_ = direct_view_get_collate_key (bview);
	_tmp4_ = _tmp3_;
	_tmp5_ = (gint64) _tmp0_ (_tmp2_, _tmp4_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	result = _tmp5_;
	return result;
}

static DataView*
direct_view_collection_direct_view_manager_real_create_view (ViewManager* base,
                                                             DataSource* source)
{
	DirectViewCollectionDirectViewManager * self;
	DirectView* _tmp0_;
	DataView* result;
	self = (DirectViewCollectionDirectViewManager*) base;
	g_return_val_if_fail (source != NULL, NULL);
	_tmp0_ = direct_view_new (G_TYPE_CHECK_INSTANCE_CAST (source, TYPE_DIRECT_PHOTO, DirectPhoto));
	result = (DataView*) _tmp0_;
	return result;
}

static DirectViewCollectionDirectViewManager*
direct_view_collection_direct_view_manager_construct (GType object_type)
{
	DirectViewCollectionDirectViewManager* self = NULL;
	self = (DirectViewCollectionDirectViewManager*) view_manager_construct (object_type);
	return self;
}

static DirectViewCollectionDirectViewManager*
direct_view_collection_direct_view_manager_new (void)
{
	return direct_view_collection_direct_view_manager_construct (DIRECT_VIEW_COLLECTION_TYPE_DIRECT_VIEW_MANAGER);
}

static void
direct_view_collection_direct_view_manager_class_init (DirectViewCollectionDirectViewManagerClass * klass,
                                                       gpointer klass_data)
{
	direct_view_collection_direct_view_manager_parent_class = g_type_class_peek_parent (klass);
	((ViewManagerClass *) klass)->create_view = (DataView* (*) (ViewManager*, DataSource*)) direct_view_collection_direct_view_manager_real_create_view;
}

static void
direct_view_collection_direct_view_manager_instance_init (DirectViewCollectionDirectViewManager * self,
                                                          gpointer klass)
{
}

static GType
direct_view_collection_direct_view_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DirectViewCollectionDirectViewManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) direct_view_collection_direct_view_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DirectViewCollectionDirectViewManager), 0, (GInstanceInitFunc) direct_view_collection_direct_view_manager_instance_init, NULL };
	GType direct_view_collection_direct_view_manager_type_id;
	direct_view_collection_direct_view_manager_type_id = g_type_register_static (TYPE_VIEW_MANAGER, "DirectViewCollectionDirectViewManager", &g_define_type_info, 0);
	return direct_view_collection_direct_view_manager_type_id;
}

static GType
direct_view_collection_direct_view_manager_get_type (void)
{
	static volatile gsize direct_view_collection_direct_view_manager_type_id__once = 0;
	if (g_once_init_enter (&direct_view_collection_direct_view_manager_type_id__once)) {
		GType direct_view_collection_direct_view_manager_type_id;
		direct_view_collection_direct_view_manager_type_id = direct_view_collection_direct_view_manager_get_type_once ();
		g_once_init_leave (&direct_view_collection_direct_view_manager_type_id__once, direct_view_collection_direct_view_manager_type_id);
	}
	return direct_view_collection_direct_view_manager_type_id__once;
}

static void
direct_view_collection_class_init (DirectViewCollectionClass * klass,
                                   gpointer klass_data)
{
	direct_view_collection_parent_class = g_type_class_peek_parent (klass);
}

static void
direct_view_collection_instance_init (DirectViewCollection * self,
                                      gpointer klass)
{
}

static GType
direct_view_collection_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DirectViewCollectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) direct_view_collection_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DirectViewCollection), 0, (GInstanceInitFunc) direct_view_collection_instance_init, NULL };
	GType direct_view_collection_type_id;
	direct_view_collection_type_id = g_type_register_static (TYPE_VIEW_COLLECTION, "DirectViewCollection", &g_define_type_info, 0);
	return direct_view_collection_type_id;
}

GType
direct_view_collection_get_type (void)
{
	static volatile gsize direct_view_collection_type_id__once = 0;
	if (g_once_init_enter (&direct_view_collection_type_id__once)) {
		GType direct_view_collection_type_id;
		direct_view_collection_type_id = direct_view_collection_get_type_once ();
		g_once_init_leave (&direct_view_collection_type_id__once, direct_view_collection_type_id);
	}
	return direct_view_collection_type_id__once;
}

