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

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/**/
/*  Copyright (C) 2011-2012 Giulio Collura*/
/*  Copyright (C) 2014 Corentin Noël <tintou@mailoo.org>*/
/**/
/*  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, see <http://www.gnu.org/licenses/>.*/
/**/

#include "slingshot.h"
#include <handy.h>
#include <gtk/gtk.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  {
	SLINGSHOT_WIDGETS_SWITCHER_0_PROPERTY,
	SLINGSHOT_WIDGETS_SWITCHER_NUM_PROPERTIES
};
static GParamSpec* slingshot_widgets_switcher_properties[SLINGSHOT_WIDGETS_SWITCHER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	SLINGSHOT_WIDGETS_SWITCHER_ON_PAGINATOR_CHANGED_SIGNAL,
	SLINGSHOT_WIDGETS_SWITCHER_NUM_SIGNALS
};
static guint slingshot_widgets_switcher_signals[SLINGSHOT_WIDGETS_SWITCHER_NUM_SIGNALS] = {0};

struct _SlingshotWidgetsSwitcherPrivate {
	HdyCarousel* paginator;
};

static gint SlingshotWidgetsSwitcher_private_offset;
static gpointer slingshot_widgets_switcher_parent_class = NULL;
static GType slingshot_widgets_switcher_type_id = 0;

static void ___lambda48_ (SlingshotWidgetsSwitcher* self,
                   GtkWidget* child);
static void ____lambda48__gfunc (gconstpointer data,
                          gpointer self);
static void slingshot_widgets_switcher_add_child (SlingshotWidgetsSwitcher* self,
                                           GtkWidget* widget);
static void _slingshot_widgets_switcher_add_child_gtk_container_add (GtkContainer* _sender,
                                                              GtkWidget* widget,
                                                              gpointer self);
static void slingshot_widgets_switcher_real_show (GtkWidget* base);
static gboolean slingshot_widgets_switcher_get_has_enough_children (SlingshotWidgetsSwitcher* self);
static void slingshot_widgets_switcher_real_show_all (GtkWidget* base);
static GObject * slingshot_widgets_switcher_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static void slingshot_widgets_switcher_finalize (GObject * obj);
static void _vala_slingshot_widgets_switcher_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);

static inline gpointer
slingshot_widgets_switcher_get_instance_private (SlingshotWidgetsSwitcher* self)
{
	return G_STRUCT_MEMBER_P (self, SlingshotWidgetsSwitcher_private_offset);
}

static void
___lambda48_ (SlingshotWidgetsSwitcher* self,
              GtkWidget* child)
{
	g_return_if_fail (child != NULL);
	gtk_widget_destroy (child);
}

static void
____lambda48__gfunc (gconstpointer data,
                     gpointer self)
{
	___lambda48_ ((SlingshotWidgetsSwitcher*) self, (GtkWidget*) data);
}

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

static void
_slingshot_widgets_switcher_add_child_gtk_container_add (GtkContainer* _sender,
                                                         GtkWidget* widget,
                                                         gpointer self)
{
	slingshot_widgets_switcher_add_child ((SlingshotWidgetsSwitcher*) self, widget);
}

void
slingshot_widgets_switcher_set_paginator (SlingshotWidgetsSwitcher* self,
                                          HdyCarousel* paginator)
{
	HdyCarousel* _tmp0_;
	HdyCarousel* _tmp3_;
	GList* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (paginator != NULL);
	_tmp0_ = self->priv->paginator;
	if (_tmp0_ != NULL) {
		GList* _tmp1_;
		GList* _tmp2_;
		_tmp1_ = gtk_container_get_children ((GtkContainer*) self);
		_tmp2_ = _tmp1_;
		g_list_foreach (_tmp2_, ____lambda48__gfunc, self);
		(_tmp2_ == NULL) ? NULL : (_tmp2_ = (g_list_free (_tmp2_), NULL));
	}
	_tmp3_ = _g_object_ref0 (paginator);
	_g_object_unref0 (self->priv->paginator);
	self->priv->paginator = _tmp3_;
	_tmp4_ = gtk_container_get_children ((GtkContainer*) paginator);
	{
		GList* child_collection = NULL;
		GList* child_it = NULL;
		child_collection = _tmp4_;
		for (child_it = child_collection; child_it != NULL; child_it = child_it->next) {
			GtkWidget* child = NULL;
			child = (GtkWidget*) child_it->data;
			{
				GtkWidget* _tmp5_;
				_tmp5_ = child;
				slingshot_widgets_switcher_add_child (self, _tmp5_);
			}
		}
		(child_collection == NULL) ? NULL : (child_collection = (g_list_free (child_collection), NULL));
	}
	g_signal_connect_object ((GtkContainer*) paginator, "add", (GCallback) _slingshot_widgets_switcher_add_child_gtk_container_add, self, G_CONNECT_AFTER);
}

static void
slingshot_widgets_switcher_add_child (SlingshotWidgetsSwitcher* self,
                                      GtkWidget* widget)
{
	SlingshotWidgetsPageChecker* button = NULL;
	HdyCarousel* _tmp0_;
	SlingshotWidgetsPageChecker* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = self->priv->paginator;
	_tmp1_ = slingshot_widgets_page_checker_new (_tmp0_, widget);
	g_object_ref_sink (_tmp1_);
	button = _tmp1_;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) button);
	_g_object_unref0 (button);
}

static void
slingshot_widgets_switcher_real_show (GtkWidget* base)
{
	SlingshotWidgetsSwitcher * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	self = (SlingshotWidgetsSwitcher*) base;
	GTK_WIDGET_CLASS (slingshot_widgets_switcher_parent_class)->show ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_grid_get_type (), GtkGrid));
	_tmp0_ = slingshot_widgets_switcher_get_has_enough_children (self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		gtk_widget_hide ((GtkWidget*) self);
	}
}

static void
slingshot_widgets_switcher_real_show_all (GtkWidget* base)
{
	SlingshotWidgetsSwitcher * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	self = (SlingshotWidgetsSwitcher*) base;
	GTK_WIDGET_CLASS (slingshot_widgets_switcher_parent_class)->show_all ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_grid_get_type (), GtkGrid));
	_tmp0_ = slingshot_widgets_switcher_get_has_enough_children (self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		gtk_widget_hide ((GtkWidget*) self);
	}
}

SlingshotWidgetsSwitcher*
slingshot_widgets_switcher_construct (GType object_type)
{
	SlingshotWidgetsSwitcher * self = NULL;
	self = (SlingshotWidgetsSwitcher*) g_object_new (object_type, NULL);
	return self;
}

SlingshotWidgetsSwitcher*
slingshot_widgets_switcher_new (void)
{
	return slingshot_widgets_switcher_construct (SLINGSHOT_WIDGETS_TYPE_SWITCHER);
}

static gboolean
slingshot_widgets_switcher_get_has_enough_children (SlingshotWidgetsSwitcher* self)
{
	gboolean result;
	GList* _tmp0_;
	GList* _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = gtk_container_get_children ((GtkContainer*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_list_length (_tmp1_) > ((guint) 1);
	(_tmp1_ == NULL) ? NULL : (_tmp1_ = (g_list_free (_tmp1_), NULL));
	result = _tmp2_;
	return result;
}

static GObject *
slingshot_widgets_switcher_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SlingshotWidgetsSwitcher * self;
	parent_class = G_OBJECT_CLASS (slingshot_widgets_switcher_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SLINGSHOT_WIDGETS_TYPE_SWITCHER, SlingshotWidgetsSwitcher);
	gtk_widget_set_halign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_HORIZONTAL);
	gtk_grid_set_column_spacing ((GtkGrid*) self, 3);
	gtk_widget_set_can_focus ((GtkWidget*) self, FALSE);
	gtk_widget_show_all ((GtkWidget*) self);
	return obj;
}

static void
slingshot_widgets_switcher_class_init (SlingshotWidgetsSwitcherClass * klass,
                                       gpointer klass_data)
{
	slingshot_widgets_switcher_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SlingshotWidgetsSwitcher_private_offset);
	((GtkWidgetClass *) klass)->show = (void (*) (GtkWidget*)) slingshot_widgets_switcher_real_show;
	((GtkWidgetClass *) klass)->show_all = (void (*) (GtkWidget*)) slingshot_widgets_switcher_real_show_all;
	G_OBJECT_CLASS (klass)->get_property = _vala_slingshot_widgets_switcher_get_property;
	G_OBJECT_CLASS (klass)->constructor = slingshot_widgets_switcher_constructor;
	G_OBJECT_CLASS (klass)->finalize = slingshot_widgets_switcher_finalize;
	slingshot_widgets_switcher_signals[SLINGSHOT_WIDGETS_SWITCHER_ON_PAGINATOR_CHANGED_SIGNAL] = g_signal_new ("on-paginator-changed", SLINGSHOT_WIDGETS_TYPE_SWITCHER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
slingshot_widgets_switcher_instance_init (SlingshotWidgetsSwitcher * self,
                                          gpointer klass)
{
	self->priv = slingshot_widgets_switcher_get_instance_private (self);
}

static void
slingshot_widgets_switcher_finalize (GObject * obj)
{
	SlingshotWidgetsSwitcher * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SLINGSHOT_WIDGETS_TYPE_SWITCHER, SlingshotWidgetsSwitcher);
	_g_object_unref0 (self->priv->paginator);
	G_OBJECT_CLASS (slingshot_widgets_switcher_parent_class)->finalize (obj);
}

GType
slingshot_widgets_switcher_get_type (void)
{
	return slingshot_widgets_switcher_type_id;
}

GType
slingshot_widgets_switcher_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (SlingshotWidgetsSwitcherClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) slingshot_widgets_switcher_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SlingshotWidgetsSwitcher), 0, (GInstanceInitFunc) slingshot_widgets_switcher_instance_init, NULL };
	slingshot_widgets_switcher_type_id = g_type_module_register_type (module, gtk_grid_get_type (), "SlingshotWidgetsSwitcher", &g_define_type_info, 0);
	SlingshotWidgetsSwitcher_private_offset = sizeof (SlingshotWidgetsSwitcherPrivate);
	return slingshot_widgets_switcher_type_id;
}

static void
_vala_slingshot_widgets_switcher_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	SlingshotWidgetsSwitcher * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SLINGSHOT_WIDGETS_TYPE_SWITCHER, SlingshotWidgetsSwitcher);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

