/* QuickAdd.c generated by valac 0.56.19, the Vala compiler
 * generated from QuickAdd.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 <adwaita.h>
#include <glib-object.h>
#include "planify.h"
#include <gee.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.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_TYPE_QUICK_ADD (dialogs_quick_add_get_type ())
#define DIALOGS_QUICK_ADD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_TYPE_QUICK_ADD, DialogsQuickAdd))
#define DIALOGS_QUICK_ADD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_TYPE_QUICK_ADD, DialogsQuickAddClass))
#define DIALOGS_IS_QUICK_ADD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_TYPE_QUICK_ADD))
#define DIALOGS_IS_QUICK_ADD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_TYPE_QUICK_ADD))
#define DIALOGS_QUICK_ADD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_TYPE_QUICK_ADD, DialogsQuickAddClass))

typedef struct _DialogsQuickAdd DialogsQuickAdd;
typedef struct _DialogsQuickAddClass DialogsQuickAddClass;
typedef struct _DialogsQuickAddPrivate DialogsQuickAddPrivate;
enum  {
	DIALOGS_QUICK_ADD_0_PROPERTY,
	DIALOGS_QUICK_ADD_ITEM_PROPERTY,
	DIALOGS_QUICK_ADD_POSITION_PROPERTY,
	DIALOGS_QUICK_ADD_NUM_PROPERTIES
};
static GParamSpec* dialogs_quick_add_properties[DIALOGS_QUICK_ADD_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block88Data Block88Data;

struct _DialogsQuickAdd {
	AdwDialog parent_instance;
	DialogsQuickAddPrivate * priv;
};

struct _DialogsQuickAddClass {
	AdwDialogClass parent_class;
};

struct _DialogsQuickAddPrivate {
	ObjectsItem* _item;
	LayoutsQuickAddCore* quick_add_widget;
	GeeHashMap* signal_map;
};

struct _Block88Data {
	int _ref_count_;
	DialogsQuickAdd* self;
	gboolean active;
};

static gint DialogsQuickAdd_private_offset;
static gpointer dialogs_quick_add_parent_class = NULL;

VALA_EXTERN GType dialogs_quick_add_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsQuickAdd, g_object_unref)
VALA_EXTERN DialogsQuickAdd* dialogs_quick_add_new (void);
VALA_EXTERN DialogsQuickAdd* dialogs_quick_add_construct (GType object_type);
static void dialogs_quick_add_add_item_db (DialogsQuickAdd* self,
                                    ObjectsItem* item,
                                    GeeArrayList* reminders);
VALA_EXTERN void dialogs_quick_add_update_content (DialogsQuickAdd* self,
                                       const gchar* content);
VALA_EXTERN void dialogs_quick_add_set_project (DialogsQuickAdd* self,
                                    ObjectsProject* project);
VALA_EXTERN void dialogs_quick_add_set_due (DialogsQuickAdd* self,
                                GDateTime* date);
VALA_EXTERN void dialogs_quick_add_set_priority (DialogsQuickAdd* self,
                                     gint priority);
VALA_EXTERN void dialogs_quick_add_set_pinned (DialogsQuickAdd* self,
                                   gboolean pinned);
VALA_EXTERN void dialogs_quick_add_for_base_object (DialogsQuickAdd* self,
                                        ObjectsBaseObject* base_object);
VALA_EXTERN void dialogs_quick_add_set_labels (DialogsQuickAdd* self,
                                   GeeHashMap* new_labels);
VALA_EXTERN void dialogs_quick_add_set_new_task_position (DialogsQuickAdd* self,
                                              NewTaskPosition value);
VALA_EXTERN void dialogs_quick_add_clean_up (DialogsQuickAdd* self);
VALA_EXTERN ObjectsItem* dialogs_quick_add_get_item (DialogsQuickAdd* self);
static void dialogs_quick_add_set_item (DialogsQuickAdd* self,
                                 ObjectsItem* value);
VALA_EXTERN gint dialogs_quick_add_get_position (DialogsQuickAdd* self);
VALA_EXTERN void dialogs_quick_add_set_position (DialogsQuickAdd* self,
                                     gint value);
static GObject * dialogs_quick_add_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static void _dialogs_quick_add___lambda75_ (DialogsQuickAdd* self);
static void __dialogs_quick_add___lambda75__layouts_quick_add_core_hide_destroy (LayoutsQuickAddCore* _sender,
                                                                          gpointer self);
static void _dialogs_quick_add_add_item_db_layouts_quick_add_core_add_item_db (LayoutsQuickAddCore* _sender,
                                                                        ObjectsItem* item,
                                                                        GeeArrayList* reminders,
                                                                        gpointer self);
static void _dialogs_quick_add___lambda76_ (DialogsQuickAdd* self,
                                     gboolean active);
static Block88Data* block88_data_ref (Block88Data* _data88_);
static void block88_data_unref (void * _userdata_);
static gboolean __lambda77_ (Block88Data* _data88_);
static gboolean ___lambda77__gsource_func (gpointer self);
static void __dialogs_quick_add___lambda76__layouts_quick_add_core_parent_can_close (LayoutsQuickAddCore* _sender,
                                                                              gboolean active,
                                                                              gpointer self);
static void _dialogs_quick_add___lambda78_ (DialogsQuickAdd* self,
                                     HttpResponse* response);
static void __dialogs_quick_add___lambda78__layouts_quick_add_core_error (LayoutsQuickAddCore* _sender,
                                                                   HttpResponse* response,
                                                                   gpointer self);
static void _dialogs_quick_add___lambda79_ (DialogsQuickAdd* self);
static void __dialogs_quick_add___lambda79__adw_dialog_closed (AdwDialog* _sender,
                                                        gpointer self);
static void dialogs_quick_add_finalize (GObject * obj);
static GType dialogs_quick_add_get_type_once (void);
static void _vala_dialogs_quick_add_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_dialogs_quick_add_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);

static inline gpointer
dialogs_quick_add_get_instance_private (DialogsQuickAdd* self)
{
	return G_STRUCT_MEMBER_P (self, DialogsQuickAdd_private_offset);
}

DialogsQuickAdd*
dialogs_quick_add_construct (GType object_type)
{
	DialogsQuickAdd * self = NULL;
	self = (DialogsQuickAdd*) g_object_new (object_type, "content-width", 550, NULL);
	return self;
}

DialogsQuickAdd*
dialogs_quick_add_new (void)
{
	return dialogs_quick_add_construct (DIALOGS_TYPE_QUICK_ADD);
}

static void
dialogs_quick_add_add_item_db (DialogsQuickAdd* self,
                               ObjectsItem* item,
                               GeeArrayList* reminders)
{
	ServicesStore* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean _tmp12_ = FALSE;
	ServicesSettings* _tmp13_;
	ServicesSettings* _tmp14_;
	gboolean _tmp15_;
	ServicesEventBus* _tmp22_;
	ServicesEventBus* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	LayoutsQuickAddCore* _tmp28_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	g_return_if_fail (reminders != NULL);
	_tmp0_ = services_store_instance ();
	services_store_insert_item (_tmp0_, item, TRUE, TRUE);
	_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) reminders);
	_tmp2_ = _tmp1_;
	if (_tmp2_ > 0) {
		LayoutsQuickAddCore* _tmp3_;
		_tmp3_ = self->priv->quick_add_widget;
		layouts_quick_add_core_set_is_loading (_tmp3_, TRUE);
		{
			GeeArrayList* _reminder_list = NULL;
			gint _reminder_size = 0;
			GeeArrayList* _tmp4_;
			gint _tmp5_;
			gint _tmp6_;
			gint _reminder_index = 0;
			_reminder_list = reminders;
			_tmp4_ = _reminder_list;
			_tmp5_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp4_);
			_tmp6_ = _tmp5_;
			_reminder_size = _tmp6_;
			_reminder_index = -1;
			while (TRUE) {
				gint _tmp7_;
				gint _tmp8_;
				ObjectsReminder* reminder = NULL;
				GeeArrayList* _tmp9_;
				gpointer _tmp10_;
				ObjectsReminder* _tmp11_;
				_reminder_index = _reminder_index + 1;
				_tmp7_ = _reminder_index;
				_tmp8_ = _reminder_size;
				if (!(_tmp7_ < _tmp8_)) {
					break;
				}
				_tmp9_ = _reminder_list;
				_tmp10_ = gee_abstract_list_get ((GeeAbstractList*) _tmp9_, _reminder_index);
				reminder = (ObjectsReminder*) _tmp10_;
				_tmp11_ = reminder;
				objects_item_add_reminder (item, _tmp11_);
				_g_object_unref0 (reminder);
			}
		}
	}
	_tmp13_ = services_settings_get_default ();
	_tmp14_ = _tmp13_;
	_tmp15_ = services_settings_get_boolean (_tmp14_, "automatic-reminders-enabled");
	_g_object_unref0 (_tmp14_);
	if (_tmp15_) {
		gboolean _tmp16_;
		gboolean _tmp17_;
		_tmp16_ = objects_item_get_has_time (item);
		_tmp17_ = _tmp16_;
		_tmp12_ = _tmp17_;
	} else {
		_tmp12_ = FALSE;
	}
	if (_tmp12_) {
		ObjectsReminder* reminder = NULL;
		ObjectsReminder* _tmp18_;
		ObjectsReminder* _tmp19_;
		ObjectsReminder* _tmp20_;
		ObjectsReminder* _tmp21_;
		_tmp18_ = objects_reminder_new ();
		reminder = _tmp18_;
		_tmp19_ = reminder;
		objects_reminder_set_mm_offset (_tmp19_, util_get_reminders_mm_offset ());
		_tmp20_ = reminder;
		objects_reminder_set_reminder_type (_tmp20_, REMINDER_TYPE_RELATIVE);
		_tmp21_ = reminder;
		objects_item_add_reminder (item, _tmp21_);
		_g_object_unref0 (reminder);
	}
	_tmp22_ = services_event_bus_get_default ();
	_tmp23_ = _tmp22_;
	_tmp24_ = objects_item_get_project_id (item);
	_tmp25_ = _tmp24_;
	_tmp26_ = objects_item_get_section_id (item);
	_tmp27_ = _tmp26_;
	g_signal_emit_by_name (_tmp23_, "update-section-sort-func", _tmp25_, _tmp27_, FALSE);
	_g_object_unref0 (_tmp23_);
	_tmp28_ = self->priv->quick_add_widget;
	layouts_quick_add_core_added_successfully (_tmp28_);
}

void
dialogs_quick_add_update_content (DialogsQuickAdd* self,
                                  const gchar* content)
{
	LayoutsQuickAddCore* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (content != NULL);
	_tmp0_ = self->priv->quick_add_widget;
	layouts_quick_add_core_update_content (_tmp0_, content);
}

void
dialogs_quick_add_set_project (DialogsQuickAdd* self,
                               ObjectsProject* project)
{
	LayoutsQuickAddCore* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (project != NULL);
	_tmp0_ = self->priv->quick_add_widget;
	layouts_quick_add_core_for_project (_tmp0_, project);
}

void
dialogs_quick_add_set_due (DialogsQuickAdd* self,
                           GDateTime* date)
{
	LayoutsQuickAddCore* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (date != NULL);
	_tmp0_ = self->priv->quick_add_widget;
	layouts_quick_add_core_set_due (_tmp0_, date);
}

void
dialogs_quick_add_set_priority (DialogsQuickAdd* self,
                                gint priority)
{
	LayoutsQuickAddCore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->quick_add_widget;
	layouts_quick_add_core_set_priority (_tmp0_, priority);
}

void
dialogs_quick_add_set_pinned (DialogsQuickAdd* self,
                              gboolean pinned)
{
	LayoutsQuickAddCore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->quick_add_widget;
	layouts_quick_add_core_set_pinned (_tmp0_, pinned);
}

void
dialogs_quick_add_for_base_object (DialogsQuickAdd* self,
                                   ObjectsBaseObject* base_object)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (base_object != NULL);
	if (G_TYPE_CHECK_INSTANCE_TYPE (base_object, OBJECTS_TYPE_PROJECT)) {
		LayoutsQuickAddCore* _tmp0_;
		_tmp0_ = self->priv->quick_add_widget;
		layouts_quick_add_core_for_project (_tmp0_, G_TYPE_CHECK_INSTANCE_TYPE (base_object, OBJECTS_TYPE_PROJECT) ? ((ObjectsProject*) base_object) : NULL);
	} else {
		if (G_TYPE_CHECK_INSTANCE_TYPE (base_object, OBJECTS_TYPE_SECTION)) {
			LayoutsQuickAddCore* _tmp1_;
			_tmp1_ = self->priv->quick_add_widget;
			layouts_quick_add_core_for_section (_tmp1_, G_TYPE_CHECK_INSTANCE_TYPE (base_object, OBJECTS_TYPE_SECTION) ? ((ObjectsSection*) base_object) : NULL);
		} else {
			if (G_TYPE_CHECK_INSTANCE_TYPE (base_object, OBJECTS_TYPE_ITEM)) {
				LayoutsQuickAddCore* _tmp2_;
				_tmp2_ = self->priv->quick_add_widget;
				layouts_quick_add_core_for_parent (_tmp2_, G_TYPE_CHECK_INSTANCE_TYPE (base_object, OBJECTS_TYPE_ITEM) ? ((ObjectsItem*) base_object) : NULL);
			}
		}
	}
}

void
dialogs_quick_add_set_labels (DialogsQuickAdd* self,
                              GeeHashMap* new_labels)
{
	LayoutsQuickAddCore* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (new_labels != NULL);
	_tmp0_ = self->priv->quick_add_widget;
	layouts_quick_add_core_set_labels (_tmp0_, new_labels);
}

void
dialogs_quick_add_set_new_task_position (DialogsQuickAdd* self,
                                         NewTaskPosition value)
{
	LayoutsQuickAddCore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->quick_add_widget;
	layouts_quick_add_core_set_new_task_position (_tmp0_, value);
}

void
dialogs_quick_add_clean_up (DialogsQuickAdd* self)
{
	GeeHashMap* _tmp15_;
	LayoutsQuickAddCore* _tmp16_;
	g_return_if_fail (self != NULL);
	{
		GeeIterator* _entry_it = NULL;
		GeeHashMap* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->signal_map;
		_tmp1_ = gee_abstract_map_get_entries ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_entry_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			GeeMapEntry* entry = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GeeMapEntry* _tmp9_;
			gconstpointer _tmp10_;
			gconstpointer _tmp11_;
			GeeMapEntry* _tmp12_;
			gconstpointer _tmp13_;
			gconstpointer _tmp14_;
			_tmp6_ = _entry_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _entry_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			entry = (GeeMapEntry*) _tmp8_;
			_tmp9_ = entry;
			_tmp10_ = gee_map_entry_get_value (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = entry;
			_tmp13_ = gee_map_entry_get_key (_tmp12_);
			_tmp14_ = _tmp13_;
			g_signal_handler_disconnect ((GObject*) _tmp11_, (gulong) ((guintptr) _tmp14_));
			_g_object_unref0 (entry);
		}
		_g_object_unref0 (_entry_it);
	}
	_tmp15_ = self->priv->signal_map;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp15_);
	_tmp16_ = self->priv->quick_add_widget;
	if (_tmp16_ != NULL) {
		LayoutsQuickAddCore* _tmp17_;
		_tmp17_ = self->priv->quick_add_widget;
		layouts_quick_add_core_clean_up (_tmp17_);
	}
}

ObjectsItem*
dialogs_quick_add_get_item (DialogsQuickAdd* self)
{
	ObjectsItem* result;
	ObjectsItem* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_item;
	result = _tmp0_;
	return result;
}

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

static void
dialogs_quick_add_set_item (DialogsQuickAdd* self,
                            ObjectsItem* value)
{
	ObjectsItem* old_value;
	g_return_if_fail (self != NULL);
	old_value = dialogs_quick_add_get_item (self);
	if (old_value != value) {
		ObjectsItem* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_item);
		self->priv->_item = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dialogs_quick_add_properties[DIALOGS_QUICK_ADD_ITEM_PROPERTY]);
	}
}

gint
dialogs_quick_add_get_position (DialogsQuickAdd* self)
{
	gint result;
	LayoutsQuickAddCore* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->quick_add_widget;
	_tmp1_ = layouts_quick_add_core_get_position (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
dialogs_quick_add_set_position (DialogsQuickAdd* self,
                                gint value)
{
	LayoutsQuickAddCore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->quick_add_widget;
	layouts_quick_add_core_set_position (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, dialogs_quick_add_properties[DIALOGS_QUICK_ADD_POSITION_PROPERTY]);
}

static void
_dialogs_quick_add___lambda75_ (DialogsQuickAdd* self)
{
	adw_dialog_close ((AdwDialog*) self);
}

static void
__dialogs_quick_add___lambda75__layouts_quick_add_core_hide_destroy (LayoutsQuickAddCore* _sender,
                                                                     gpointer self)
{
	_dialogs_quick_add___lambda75_ ((DialogsQuickAdd*) self);
}

static void
_dialogs_quick_add_add_item_db_layouts_quick_add_core_add_item_db (LayoutsQuickAddCore* _sender,
                                                                   ObjectsItem* item,
                                                                   GeeArrayList* reminders,
                                                                   gpointer self)
{
	dialogs_quick_add_add_item_db ((DialogsQuickAdd*) self, item, reminders);
}

static Block88Data*
block88_data_ref (Block88Data* _data88_)
{
	g_atomic_int_inc (&_data88_->_ref_count_);
	return _data88_;
}

static void
block88_data_unref (void * _userdata_)
{
	Block88Data* _data88_;
	_data88_ = (Block88Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data88_->_ref_count_)) {
		DialogsQuickAdd* self;
		self = _data88_->self;
		_g_object_unref0 (self);
		g_slice_free (Block88Data, _data88_);
	}
}

static gboolean
__lambda77_ (Block88Data* _data88_)
{
	DialogsQuickAdd* self;
	gboolean result;
	self = _data88_->self;
	adw_dialog_set_can_close ((AdwDialog*) self, _data88_->active);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda77__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda77_ (self);
	return result;
}

static void
_dialogs_quick_add___lambda76_ (DialogsQuickAdd* self,
                                gboolean active)
{
	Block88Data* _data88_;
	_data88_ = g_slice_new0 (Block88Data);
	_data88_->_ref_count_ = 1;
	_data88_->self = g_object_ref (self);
	_data88_->active = active;
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 250, ___lambda77__gsource_func, block88_data_ref (_data88_), block88_data_unref);
	block88_data_unref (_data88_);
	_data88_ = NULL;
}

static void
__dialogs_quick_add___lambda76__layouts_quick_add_core_parent_can_close (LayoutsQuickAddCore* _sender,
                                                                         gboolean active,
                                                                         gpointer self)
{
	_dialogs_quick_add___lambda76_ ((DialogsQuickAdd*) self, active);
}

static void
_dialogs_quick_add___lambda78_ (DialogsQuickAdd* self,
                                HttpResponse* response)
{
	ServicesEventBus* _tmp0_;
	ServicesEventBus* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	g_return_if_fail (response != NULL);
	_tmp0_ = services_event_bus_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = http_response_get_error_code (response);
	_tmp3_ = _tmp2_;
	_tmp4_ = http_response_get_error (response);
	_tmp5_ = _tmp4_;
	g_signal_emit_by_name (_tmp1_, "send-error-toast", _tmp3_, _tmp5_);
	_g_object_unref0 (_tmp1_);
	adw_dialog_close ((AdwDialog*) self);
}

static void
__dialogs_quick_add___lambda78__layouts_quick_add_core_error (LayoutsQuickAddCore* _sender,
                                                              HttpResponse* response,
                                                              gpointer self)
{
	_dialogs_quick_add___lambda78_ ((DialogsQuickAdd*) self, response);
}

static void
_dialogs_quick_add___lambda79_ (DialogsQuickAdd* self)
{
	ServicesEventBus* _tmp0_;
	ServicesEventBus* _tmp1_;
	dialogs_quick_add_clean_up (self);
	_tmp0_ = services_event_bus_get_default ();
	_tmp1_ = _tmp0_;
	g_signal_emit_by_name (_tmp1_, "connect-all-accels");
	_g_object_unref0 (_tmp1_);
}

static void
__dialogs_quick_add___lambda79__adw_dialog_closed (AdwDialog* _sender,
                                                   gpointer self)
{
	_dialogs_quick_add___lambda79_ ((DialogsQuickAdd*) self);
}

static GObject *
dialogs_quick_add_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DialogsQuickAdd * self;
	ServicesEventBus* _tmp0_;
	ServicesEventBus* _tmp1_;
	LayoutsQuickAddCore* _tmp2_;
	LayoutsQuickAddCore* _tmp3_;
	GeeHashMap* _tmp4_;
	LayoutsQuickAddCore* _tmp5_;
	gulong _tmp6_;
	LayoutsQuickAddCore* _tmp7_;
	GeeHashMap* _tmp8_;
	LayoutsQuickAddCore* _tmp9_;
	gulong _tmp10_;
	LayoutsQuickAddCore* _tmp11_;
	GeeHashMap* _tmp12_;
	LayoutsQuickAddCore* _tmp13_;
	gulong _tmp14_;
	LayoutsQuickAddCore* _tmp15_;
	GeeHashMap* _tmp16_;
	LayoutsQuickAddCore* _tmp17_;
	gulong _tmp18_;
	LayoutsQuickAddCore* _tmp19_;
	parent_class = G_OBJECT_CLASS (dialogs_quick_add_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_TYPE_QUICK_ADD, DialogsQuickAdd);
	_tmp0_ = services_event_bus_get_default ();
	_tmp1_ = _tmp0_;
	g_signal_emit_by_name (_tmp1_, "disconnect-all-accels");
	_g_object_unref0 (_tmp1_);
	_tmp2_ = layouts_quick_add_core_new (FALSE);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->quick_add_widget);
	self->priv->quick_add_widget = _tmp2_;
	_tmp3_ = self->priv->quick_add_widget;
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) _tmp3_);
	_tmp4_ = self->priv->signal_map;
	_tmp5_ = self->priv->quick_add_widget;
	_tmp6_ = g_signal_connect_object (_tmp5_, "hide-destroy", (GCallback) __dialogs_quick_add___lambda75__layouts_quick_add_core_hide_destroy, self, 0);
	_tmp7_ = self->priv->quick_add_widget;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp4_, (gpointer) ((guintptr) _tmp6_), (GObject*) _tmp7_);
	_tmp8_ = self->priv->signal_map;
	_tmp9_ = self->priv->quick_add_widget;
	_tmp10_ = g_signal_connect_object (_tmp9_, "add-item-db", (GCallback) _dialogs_quick_add_add_item_db_layouts_quick_add_core_add_item_db, self, 0);
	_tmp11_ = self->priv->quick_add_widget;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp8_, (gpointer) ((guintptr) _tmp10_), (GObject*) _tmp11_);
	_tmp12_ = self->priv->signal_map;
	_tmp13_ = self->priv->quick_add_widget;
	_tmp14_ = g_signal_connect_object (_tmp13_, "parent-can-close", (GCallback) __dialogs_quick_add___lambda76__layouts_quick_add_core_parent_can_close, self, 0);
	_tmp15_ = self->priv->quick_add_widget;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp12_, (gpointer) ((guintptr) _tmp14_), (GObject*) _tmp15_);
	_tmp16_ = self->priv->signal_map;
	_tmp17_ = self->priv->quick_add_widget;
	_tmp18_ = g_signal_connect_object (_tmp17_, "error", (GCallback) __dialogs_quick_add___lambda78__layouts_quick_add_core_error, self, 0);
	_tmp19_ = self->priv->quick_add_widget;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp16_, (gpointer) ((guintptr) _tmp18_), (GObject*) _tmp19_);
	g_signal_connect_object ((AdwDialog*) self, "closed", (GCallback) __dialogs_quick_add___lambda79__adw_dialog_closed, self, 0);
	return obj;
}

static void
dialogs_quick_add_class_init (DialogsQuickAddClass * klass,
                              gpointer klass_data)
{
	dialogs_quick_add_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DialogsQuickAdd_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dialogs_quick_add_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dialogs_quick_add_set_property;
	G_OBJECT_CLASS (klass)->constructor = dialogs_quick_add_constructor;
	G_OBJECT_CLASS (klass)->finalize = dialogs_quick_add_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DIALOGS_QUICK_ADD_ITEM_PROPERTY, dialogs_quick_add_properties[DIALOGS_QUICK_ADD_ITEM_PROPERTY] = g_param_spec_object ("item", "item", "item", OBJECTS_TYPE_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DIALOGS_QUICK_ADD_POSITION_PROPERTY, dialogs_quick_add_properties[DIALOGS_QUICK_ADD_POSITION_PROPERTY] = g_param_spec_int ("position", "position", "position", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
dialogs_quick_add_instance_init (DialogsQuickAdd * self,
                                 gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = dialogs_quick_add_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_ULONG, NULL, NULL, G_TYPE_OBJECT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->signal_map = _tmp0_;
}

static void
dialogs_quick_add_finalize (GObject * obj)
{
	DialogsQuickAdd * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_TYPE_QUICK_ADD, DialogsQuickAdd);
	g_debug ("QuickAdd.vala:46: Destroying - Dialogs.QuickAdd\n");
	_g_object_unref0 (self->priv->_item);
	_g_object_unref0 (self->priv->quick_add_widget);
	_g_object_unref0 (self->priv->signal_map);
	G_OBJECT_CLASS (dialogs_quick_add_parent_class)->finalize (obj);
}

static GType
dialogs_quick_add_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DialogsQuickAddClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dialogs_quick_add_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DialogsQuickAdd), 0, (GInstanceInitFunc) dialogs_quick_add_instance_init, NULL };
	GType dialogs_quick_add_type_id;
	dialogs_quick_add_type_id = g_type_register_static (adw_dialog_get_type (), "DialogsQuickAdd", &g_define_type_info, 0);
	DialogsQuickAdd_private_offset = g_type_add_instance_private (dialogs_quick_add_type_id, sizeof (DialogsQuickAddPrivate));
	return dialogs_quick_add_type_id;
}

GType
dialogs_quick_add_get_type (void)
{
	static volatile gsize dialogs_quick_add_type_id__once = 0;
	if (g_once_init_enter (&dialogs_quick_add_type_id__once)) {
		GType dialogs_quick_add_type_id;
		dialogs_quick_add_type_id = dialogs_quick_add_get_type_once ();
		g_once_init_leave (&dialogs_quick_add_type_id__once, dialogs_quick_add_type_id);
	}
	return dialogs_quick_add_type_id__once;
}

static void
_vala_dialogs_quick_add_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	DialogsQuickAdd * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_TYPE_QUICK_ADD, DialogsQuickAdd);
	switch (property_id) {
		case DIALOGS_QUICK_ADD_ITEM_PROPERTY:
		g_value_set_object (value, dialogs_quick_add_get_item (self));
		break;
		case DIALOGS_QUICK_ADD_POSITION_PROPERTY:
		g_value_set_int (value, dialogs_quick_add_get_position (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dialogs_quick_add_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	DialogsQuickAdd * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_TYPE_QUICK_ADD, DialogsQuickAdd);
	switch (property_id) {
		case DIALOGS_QUICK_ADD_ITEM_PROPERTY:
		dialogs_quick_add_set_item (self, g_value_get_object (value));
		break;
		case DIALOGS_QUICK_ADD_POSITION_PROPERTY:
		dialogs_quick_add_set_position (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

