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

/*
 * Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 3 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
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include "planify.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_SECTION_SORTER (dialogs_quick_find_quick_find_section_sorter_get_type ())
#define DIALOGS_QUICK_FIND_QUICK_FIND_SECTION_SORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_SECTION_SORTER, DialogsQuickFindQuickFindSectionSorter))
#define DIALOGS_QUICK_FIND_QUICK_FIND_SECTION_SORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_SECTION_SORTER, DialogsQuickFindQuickFindSectionSorterClass))
#define DIALOGS_QUICK_FIND_IS_QUICK_FIND_SECTION_SORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_SECTION_SORTER))
#define DIALOGS_QUICK_FIND_IS_QUICK_FIND_SECTION_SORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_SECTION_SORTER))
#define DIALOGS_QUICK_FIND_QUICK_FIND_SECTION_SORTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_SECTION_SORTER, DialogsQuickFindQuickFindSectionSorterClass))

typedef struct _DialogsQuickFindQuickFindSectionSorter DialogsQuickFindQuickFindSectionSorter;
typedef struct _DialogsQuickFindQuickFindSectionSorterClass DialogsQuickFindQuickFindSectionSorterClass;
typedef struct _DialogsQuickFindQuickFindSectionSorterPrivate DialogsQuickFindQuickFindSectionSorterPrivate;
enum  {
	DIALOGS_QUICK_FIND_QUICK_FIND_SECTION_SORTER_0_PROPERTY,
	DIALOGS_QUICK_FIND_QUICK_FIND_SECTION_SORTER_NUM_PROPERTIES
};
static GParamSpec* dialogs_quick_find_quick_find_section_sorter_properties[DIALOGS_QUICK_FIND_QUICK_FIND_SECTION_SORTER_NUM_PROPERTIES];

#define DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_ITEM (dialogs_quick_find_quick_find_item_get_type ())
#define DIALOGS_QUICK_FIND_QUICK_FIND_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_ITEM, DialogsQuickFindQuickFindItem))
#define DIALOGS_QUICK_FIND_QUICK_FIND_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_ITEM, DialogsQuickFindQuickFindItemClass))
#define DIALOGS_QUICK_FIND_IS_QUICK_FIND_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_ITEM))
#define DIALOGS_QUICK_FIND_IS_QUICK_FIND_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_ITEM))
#define DIALOGS_QUICK_FIND_QUICK_FIND_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_ITEM, DialogsQuickFindQuickFindItemClass))

typedef struct _DialogsQuickFindQuickFindItem DialogsQuickFindQuickFindItem;
typedef struct _DialogsQuickFindQuickFindItemClass DialogsQuickFindQuickFindItemClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _DialogsQuickFindQuickFindSectionSorter {
	GtkSorter parent_instance;
	DialogsQuickFindQuickFindSectionSorterPrivate * priv;
};

struct _DialogsQuickFindQuickFindSectionSorterClass {
	GtkSorterClass parent_class;
};

static gpointer dialogs_quick_find_quick_find_section_sorter_parent_class = NULL;

VALA_EXTERN GType dialogs_quick_find_quick_find_section_sorter_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsQuickFindQuickFindSectionSorter, g_object_unref)
static GtkOrdering dialogs_quick_find_quick_find_section_sorter_real_compare (GtkSorter* base,
                                                                       GObject* item1,
                                                                       GObject* item2);
VALA_EXTERN GType dialogs_quick_find_quick_find_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsQuickFindQuickFindItem, g_object_unref)
VALA_EXTERN ObjectsBaseObject* dialogs_quick_find_quick_find_item_get_base_object (DialogsQuickFindQuickFindItem* self);
static gint dialogs_quick_find_quick_find_section_sorter_get_type_order (DialogsQuickFindQuickFindSectionSorter* self,
                                                                  ObjectType type);
static GtkSorterOrder dialogs_quick_find_quick_find_section_sorter_real_get_order (GtkSorter* base);
VALA_EXTERN DialogsQuickFindQuickFindSectionSorter* dialogs_quick_find_quick_find_section_sorter_new (void);
VALA_EXTERN DialogsQuickFindQuickFindSectionSorter* dialogs_quick_find_quick_find_section_sorter_construct (GType object_type);
static GType dialogs_quick_find_quick_find_section_sorter_get_type_once (void);

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

static GtkOrdering
dialogs_quick_find_quick_find_section_sorter_real_compare (GtkSorter* base,
                                                           GObject* item1,
                                                           GObject* item2)
{
	DialogsQuickFindQuickFindSectionSorter * self;
	DialogsQuickFindQuickFindItem* a = NULL;
	DialogsQuickFindQuickFindItem* _tmp0_;
	DialogsQuickFindQuickFindItem* _tmp1_;
	DialogsQuickFindQuickFindItem* b = NULL;
	DialogsQuickFindQuickFindItem* _tmp2_;
	DialogsQuickFindQuickFindItem* _tmp3_;
	ObjectType type_a = 0;
	DialogsQuickFindQuickFindItem* _tmp4_;
	ObjectsBaseObject* _tmp5_;
	ObjectsBaseObject* _tmp6_;
	ObjectType _tmp7_;
	ObjectType _tmp8_;
	ObjectType type_b = 0;
	DialogsQuickFindQuickFindItem* _tmp9_;
	ObjectsBaseObject* _tmp10_;
	ObjectsBaseObject* _tmp11_;
	ObjectType _tmp12_;
	ObjectType _tmp13_;
	GtkOrdering result;
	self = (DialogsQuickFindQuickFindSectionSorter*) base;
	_tmp0_ = _g_object_ref0 (DIALOGS_QUICK_FIND_IS_QUICK_FIND_ITEM (item1) ? ((DialogsQuickFindQuickFindItem*) item1) : NULL);
	a = _tmp0_;
	_tmp1_ = a;
	if (_tmp1_ == NULL) {
		result = GTK_ORDERING_SMALLER;
		_g_object_unref0 (a);
		return result;
	}
	_tmp2_ = _g_object_ref0 (DIALOGS_QUICK_FIND_IS_QUICK_FIND_ITEM (item2) ? ((DialogsQuickFindQuickFindItem*) item2) : NULL);
	b = _tmp2_;
	_tmp3_ = b;
	if (_tmp3_ == NULL) {
		result = GTK_ORDERING_LARGER;
		_g_object_unref0 (b);
		_g_object_unref0 (a);
		return result;
	}
	_tmp4_ = a;
	_tmp5_ = dialogs_quick_find_quick_find_item_get_base_object (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = objects_base_object_get_object_type (_tmp6_);
	_tmp8_ = _tmp7_;
	type_a = _tmp8_;
	_tmp9_ = b;
	_tmp10_ = dialogs_quick_find_quick_find_item_get_base_object (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = objects_base_object_get_object_type (_tmp11_);
	_tmp13_ = _tmp12_;
	type_b = _tmp13_;
	if (type_a != type_b) {
		gint order_a = 0;
		gint order_b = 0;
		order_a = dialogs_quick_find_quick_find_section_sorter_get_type_order (self, type_a);
		order_b = dialogs_quick_find_quick_find_section_sorter_get_type_order (self, type_b);
		if (order_a < order_b) {
			result = GTK_ORDERING_SMALLER;
			_g_object_unref0 (b);
			_g_object_unref0 (a);
			return result;
		} else {
			result = GTK_ORDERING_LARGER;
			_g_object_unref0 (b);
			_g_object_unref0 (a);
			return result;
		}
	}
	result = GTK_ORDERING_EQUAL;
	_g_object_unref0 (b);
	_g_object_unref0 (a);
	return result;
}

static gint
dialogs_quick_find_quick_find_section_sorter_get_type_order (DialogsQuickFindQuickFindSectionSorter* self,
                                                             ObjectType type)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	switch (type) {
		case OBJECT_TYPE_FILTER:
		{
			result = 0;
			return result;
		}
		case OBJECT_TYPE_PROJECT:
		{
			result = 1;
			return result;
		}
		case OBJECT_TYPE_SECTION:
		{
			result = 2;
			return result;
		}
		case OBJECT_TYPE_ITEM:
		{
			result = 3;
			return result;
		}
		case OBJECT_TYPE_LABEL:
		{
			result = 4;
			return result;
		}
		default:
		{
			result = 99;
			return result;
		}
	}
}

static GtkSorterOrder
dialogs_quick_find_quick_find_section_sorter_real_get_order (GtkSorter* base)
{
	DialogsQuickFindQuickFindSectionSorter * self;
	GtkSorterOrder result;
	self = (DialogsQuickFindQuickFindSectionSorter*) base;
	result = GTK_SORTER_ORDER_PARTIAL;
	return result;
}

DialogsQuickFindQuickFindSectionSorter*
dialogs_quick_find_quick_find_section_sorter_construct (GType object_type)
{
	DialogsQuickFindQuickFindSectionSorter * self = NULL;
	self = (DialogsQuickFindQuickFindSectionSorter*) g_object_new (object_type, NULL);
	return self;
}

DialogsQuickFindQuickFindSectionSorter*
dialogs_quick_find_quick_find_section_sorter_new (void)
{
	return dialogs_quick_find_quick_find_section_sorter_construct (DIALOGS_QUICK_FIND_TYPE_QUICK_FIND_SECTION_SORTER);
}

static void
dialogs_quick_find_quick_find_section_sorter_class_init (DialogsQuickFindQuickFindSectionSorterClass * klass,
                                                         gpointer klass_data)
{
	dialogs_quick_find_quick_find_section_sorter_parent_class = g_type_class_peek_parent (klass);
	((GtkSorterClass *) klass)->compare = (GtkOrdering (*) (GtkSorter*, GObject*, GObject*)) dialogs_quick_find_quick_find_section_sorter_real_compare;
	((GtkSorterClass *) klass)->get_order = (GtkSorterOrder (*) (GtkSorter*)) dialogs_quick_find_quick_find_section_sorter_real_get_order;
}

static void
dialogs_quick_find_quick_find_section_sorter_instance_init (DialogsQuickFindQuickFindSectionSorter * self,
                                                            gpointer klass)
{
}

static GType
dialogs_quick_find_quick_find_section_sorter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DialogsQuickFindQuickFindSectionSorterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dialogs_quick_find_quick_find_section_sorter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DialogsQuickFindQuickFindSectionSorter), 0, (GInstanceInitFunc) dialogs_quick_find_quick_find_section_sorter_instance_init, NULL };
	GType dialogs_quick_find_quick_find_section_sorter_type_id;
	dialogs_quick_find_quick_find_section_sorter_type_id = g_type_register_static (gtk_sorter_get_type (), "DialogsQuickFindQuickFindSectionSorter", &g_define_type_info, 0);
	return dialogs_quick_find_quick_find_section_sorter_type_id;
}

GType
dialogs_quick_find_quick_find_section_sorter_get_type (void)
{
	static volatile gsize dialogs_quick_find_quick_find_section_sorter_type_id__once = 0;
	if (g_once_init_enter (&dialogs_quick_find_quick_find_section_sorter_type_id__once)) {
		GType dialogs_quick_find_quick_find_section_sorter_type_id;
		dialogs_quick_find_quick_find_section_sorter_type_id = dialogs_quick_find_quick_find_section_sorter_get_type_once ();
		g_once_init_leave (&dialogs_quick_find_quick_find_section_sorter_type_id__once, dialogs_quick_find_quick_find_section_sorter_type_id);
	}
	return dialogs_quick_find_quick_find_section_sorter_type_id__once;
}

