/* ImportQueueSidebarEntry.c generated by valac 0.56.19, the Vala compiler
 * generated from ImportQueueSidebarEntry.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 <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.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  {
	LIBRARY_IMPORT_QUEUE_SIDEBAR_ENTRY_0_PROPERTY,
	LIBRARY_IMPORT_QUEUE_SIDEBAR_ENTRY_NUM_PROPERTIES
};
static GParamSpec* library_import_queue_sidebar_entry_properties[LIBRARY_IMPORT_QUEUE_SIDEBAR_ENTRY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer library_import_queue_sidebar_entry_parent_class = NULL;

static void library_import_queue_sidebar_entry_on_page_created (LibraryImportQueueSidebarEntry* self);
static void _library_import_queue_sidebar_entry_on_page_created_sidebar_page_representative_page_created (SidebarPageRepresentative* _sender,
                                                                                                   Page* page,
                                                                                                   gpointer self);
static void library_import_queue_sidebar_entry_on_destroying_page (LibraryImportQueueSidebarEntry* self);
static void _library_import_queue_sidebar_entry_on_destroying_page_sidebar_page_representative_destroying_page (SidebarPageRepresentative* _sender,
                                                                                                         Page* page,
                                                                                                         gpointer self);
static gchar* library_import_queue_sidebar_entry_real_get_sidebar_name (SidebarSimplePageEntry* base);
static GIcon* library_import_queue_sidebar_entry_real_get_sidebar_icon (SidebarSimplePageEntry* base);
static Page* library_import_queue_sidebar_entry_real_create_page (SidebarSimplePageEntry* base);
static ImportQueuePage* library_import_queue_sidebar_entry_get_queue_page (LibraryImportQueueSidebarEntry* self);
static void library_import_queue_sidebar_entry_on_batch_added_or_removed (LibraryImportQueueSidebarEntry* self);
static void _library_import_queue_sidebar_entry_on_batch_added_or_removed_import_queue_page_batch_added (ImportQueuePage* _sender,
                                                                                                  BatchImport* batch_import,
                                                                                                  gpointer self);
static void _library_import_queue_sidebar_entry_on_batch_added_or_removed_import_queue_page_batch_removed (ImportQueuePage* _sender,
                                                                                                    BatchImport* batch_import,
                                                                                                    gpointer self);
static GType library_import_queue_sidebar_entry_get_type_once (void);

static void
_library_import_queue_sidebar_entry_on_page_created_sidebar_page_representative_page_created (SidebarPageRepresentative* _sender,
                                                                                              Page* page,
                                                                                              gpointer self)
{
	library_import_queue_sidebar_entry_on_page_created ((LibraryImportQueueSidebarEntry*) self);
}

static void
_library_import_queue_sidebar_entry_on_destroying_page_sidebar_page_representative_destroying_page (SidebarPageRepresentative* _sender,
                                                                                                    Page* page,
                                                                                                    gpointer self)
{
	library_import_queue_sidebar_entry_on_destroying_page ((LibraryImportQueueSidebarEntry*) self);
}

LibraryImportQueueSidebarEntry*
library_import_queue_sidebar_entry_construct (GType object_type)
{
	LibraryImportQueueSidebarEntry * self = NULL;
	self = (LibraryImportQueueSidebarEntry*) library_hideable_page_entry_construct (object_type);
	g_signal_connect_object ((SidebarPageRepresentative*) self, "page-created", (GCallback) _library_import_queue_sidebar_entry_on_page_created_sidebar_page_representative_page_created, self, 0);
	g_signal_connect_object ((SidebarPageRepresentative*) self, "destroying-page", (GCallback) _library_import_queue_sidebar_entry_on_destroying_page_sidebar_page_representative_destroying_page, self, 0);
	library_hideable_page_entry_set_visible ((LibraryHideablePageEntry*) self, FALSE);
	return self;
}

LibraryImportQueueSidebarEntry*
library_import_queue_sidebar_entry_new (void)
{
	return library_import_queue_sidebar_entry_construct (LIBRARY_TYPE_IMPORT_QUEUE_SIDEBAR_ENTRY);
}

static gchar*
library_import_queue_sidebar_entry_real_get_sidebar_name (SidebarSimplePageEntry* base)
{
	LibraryImportQueueSidebarEntry * self;
	gchar* _tmp0_;
	gchar* result;
	self = (LibraryImportQueueSidebarEntry*) base;
	_tmp0_ = g_strdup (IMPORT_QUEUE_PAGE_NAME);
	result = _tmp0_;
	return result;
}

static GIcon*
library_import_queue_sidebar_entry_real_get_sidebar_icon (SidebarSimplePageEntry* base)
{
	LibraryImportQueueSidebarEntry * self;
	GThemedIcon* _tmp0_;
	GIcon* result;
	self = (LibraryImportQueueSidebarEntry*) base;
	_tmp0_ = (GThemedIcon*) g_themed_icon_new (RESOURCES_ICON_IMPORTING);
	result = (GIcon*) _tmp0_;
	return result;
}

static Page*
library_import_queue_sidebar_entry_real_create_page (SidebarSimplePageEntry* base)
{
	LibraryImportQueueSidebarEntry * self;
	ImportQueuePage* _tmp0_;
	Page* result;
	self = (LibraryImportQueueSidebarEntry*) base;
	_tmp0_ = import_queue_page_new ();
	g_object_ref_sink (_tmp0_);
	result = (Page*) _tmp0_;
	return result;
}

static ImportQueuePage*
library_import_queue_sidebar_entry_get_queue_page (LibraryImportQueueSidebarEntry* self)
{
	Page* _tmp0_;
	ImportQueuePage* _tmp1_;
	ImportQueuePage* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = sidebar_page_representative_get_page ((SidebarPageRepresentative*) self);
	_tmp1_ = IS_IMPORT_QUEUE_PAGE (_tmp0_) ? ((ImportQueuePage*) _tmp0_) : NULL;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (_tmp0_);
	}
	result = _tmp1_;
	return result;
}

static void
_library_import_queue_sidebar_entry_on_batch_added_or_removed_import_queue_page_batch_added (ImportQueuePage* _sender,
                                                                                             BatchImport* batch_import,
                                                                                             gpointer self)
{
	library_import_queue_sidebar_entry_on_batch_added_or_removed ((LibraryImportQueueSidebarEntry*) self);
}

static void
_library_import_queue_sidebar_entry_on_batch_added_or_removed_import_queue_page_batch_removed (ImportQueuePage* _sender,
                                                                                               BatchImport* batch_import,
                                                                                               gpointer self)
{
	library_import_queue_sidebar_entry_on_batch_added_or_removed ((LibraryImportQueueSidebarEntry*) self);
}

static void
library_import_queue_sidebar_entry_on_page_created (LibraryImportQueueSidebarEntry* self)
{
	ImportQueuePage* _tmp0_;
	ImportQueuePage* _tmp1_;
	ImportQueuePage* _tmp2_;
	ImportQueuePage* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = library_import_queue_sidebar_entry_get_queue_page (self);
	_tmp1_ = _tmp0_;
	g_signal_connect_object (_tmp1_, "batch-added", (GCallback) _library_import_queue_sidebar_entry_on_batch_added_or_removed_import_queue_page_batch_added, self, 0);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = library_import_queue_sidebar_entry_get_queue_page (self);
	_tmp3_ = _tmp2_;
	g_signal_connect_object (_tmp3_, "batch-removed", (GCallback) _library_import_queue_sidebar_entry_on_batch_added_or_removed_import_queue_page_batch_removed, self, 0);
	_g_object_unref0 (_tmp3_);
}

static void
library_import_queue_sidebar_entry_on_destroying_page (LibraryImportQueueSidebarEntry* self)
{
	ImportQueuePage* _tmp0_;
	ImportQueuePage* _tmp1_;
	guint _tmp2_;
	ImportQueuePage* _tmp3_;
	ImportQueuePage* _tmp4_;
	guint _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = library_import_queue_sidebar_entry_get_queue_page (self);
	_tmp1_ = _tmp0_;
	g_signal_parse_name ("batch-added", TYPE_IMPORT_QUEUE_PAGE, &_tmp2_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _library_import_queue_sidebar_entry_on_batch_added_or_removed_import_queue_page_batch_added, self);
	_g_object_unref0 (_tmp1_);
	_tmp3_ = library_import_queue_sidebar_entry_get_queue_page (self);
	_tmp4_ = _tmp3_;
	g_signal_parse_name ("batch-removed", TYPE_IMPORT_QUEUE_PAGE, &_tmp5_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _library_import_queue_sidebar_entry_on_batch_added_or_removed_import_queue_page_batch_removed, self);
	_g_object_unref0 (_tmp4_);
}

static void
library_import_queue_sidebar_entry_on_batch_added_or_removed (LibraryImportQueueSidebarEntry* self)
{
	ImportQueuePage* _tmp0_;
	ImportQueuePage* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = library_import_queue_sidebar_entry_get_queue_page (self);
	_tmp1_ = _tmp0_;
	library_hideable_page_entry_set_visible ((LibraryHideablePageEntry*) self, import_queue_page_get_batch_count (_tmp1_) > 0);
	_g_object_unref0 (_tmp1_);
}

void
library_import_queue_sidebar_entry_enqueue_and_schedule (LibraryImportQueueSidebarEntry* self,
                                                         BatchImport* batch_import,
                                                         gboolean allow_user_cancel)
{
	ImportQueuePage* _tmp0_;
	ImportQueuePage* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (batch_import != NULL);
	library_hideable_page_entry_set_visible ((LibraryHideablePageEntry*) self, TRUE);
	_tmp0_ = library_import_queue_sidebar_entry_get_queue_page (self);
	_tmp1_ = _tmp0_;
	import_queue_page_enqueue_and_schedule (_tmp1_, batch_import, allow_user_cancel);
	_g_object_unref0 (_tmp1_);
}

static void
library_import_queue_sidebar_entry_class_init (LibraryImportQueueSidebarEntryClass * klass,
                                               gpointer klass_data)
{
	library_import_queue_sidebar_entry_parent_class = g_type_class_peek_parent (klass);
	((SidebarSimplePageEntryClass *) klass)->get_sidebar_name = (gchar* (*) (SidebarSimplePageEntry*)) library_import_queue_sidebar_entry_real_get_sidebar_name;
	((SidebarSimplePageEntryClass *) klass)->get_sidebar_icon = (GIcon* (*) (SidebarSimplePageEntry*)) library_import_queue_sidebar_entry_real_get_sidebar_icon;
	((SidebarSimplePageEntryClass *) klass)->create_page = (Page* (*) (SidebarSimplePageEntry*)) library_import_queue_sidebar_entry_real_create_page;
}

static void
library_import_queue_sidebar_entry_instance_init (LibraryImportQueueSidebarEntry * self,
                                                  gpointer klass)
{
}

static GType
library_import_queue_sidebar_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (LibraryImportQueueSidebarEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) library_import_queue_sidebar_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LibraryImportQueueSidebarEntry), 0, (GInstanceInitFunc) library_import_queue_sidebar_entry_instance_init, NULL };
	GType library_import_queue_sidebar_entry_type_id;
	library_import_queue_sidebar_entry_type_id = g_type_register_static (LIBRARY_TYPE_HIDEABLE_PAGE_ENTRY, "LibraryImportQueueSidebarEntry", &g_define_type_info, 0);
	return library_import_queue_sidebar_entry_type_id;
}

GType
library_import_queue_sidebar_entry_get_type (void)
{
	static volatile gsize library_import_queue_sidebar_entry_type_id__once = 0;
	if (g_once_init_enter (&library_import_queue_sidebar_entry_type_id__once)) {
		GType library_import_queue_sidebar_entry_type_id;
		library_import_queue_sidebar_entry_type_id = library_import_queue_sidebar_entry_get_type_once ();
		g_once_init_leave (&library_import_queue_sidebar_entry_type_id__once, library_import_queue_sidebar_entry_type_id);
	}
	return library_import_queue_sidebar_entry_type_id__once;
}

