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

/*
 * Copyright 2011–2019 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include "granite.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.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 TYPE_DYNAMIC_NOTEBOOK_VIEW (dynamic_notebook_view_get_type ())
#define DYNAMIC_NOTEBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DYNAMIC_NOTEBOOK_VIEW, DynamicNotebookView))
#define DYNAMIC_NOTEBOOK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DYNAMIC_NOTEBOOK_VIEW, DynamicNotebookViewClass))
#define IS_DYNAMIC_NOTEBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DYNAMIC_NOTEBOOK_VIEW))
#define IS_DYNAMIC_NOTEBOOK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DYNAMIC_NOTEBOOK_VIEW))
#define DYNAMIC_NOTEBOOK_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DYNAMIC_NOTEBOOK_VIEW, DynamicNotebookViewClass))

typedef struct _DynamicNotebookView DynamicNotebookView;
typedef struct _DynamicNotebookViewClass DynamicNotebookViewClass;
typedef struct _DynamicNotebookViewPrivate DynamicNotebookViewPrivate;
enum  {
	DYNAMIC_NOTEBOOK_VIEW_0_PROPERTY,
	DYNAMIC_NOTEBOOK_VIEW_NUM_PROPERTIES
};
static GParamSpec* dynamic_notebook_view_properties[DYNAMIC_NOTEBOOK_VIEW_NUM_PROPERTIES];
typedef struct _Block8Data Block8Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _DynamicNotebookView {
	GtkGrid parent_instance;
	DynamicNotebookViewPrivate * priv;
};

struct _DynamicNotebookViewClass {
	GtkGridClass parent_class;
};

struct _Block8Data {
	int _ref_count_;
	DynamicNotebookView* self;
	GraniteWidgetsDynamicNotebook* notebook;
	gint i;
};

static gpointer dynamic_notebook_view_parent_class = NULL;

VALA_EXTERN GType dynamic_notebook_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DynamicNotebookView, g_object_unref)
VALA_EXTERN DynamicNotebookView* dynamic_notebook_view_new (void);
VALA_EXTERN DynamicNotebookView* dynamic_notebook_view_construct (GType object_type);
static GObject * dynamic_notebook_view_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static void _dynamic_notebook_view___lambda8_ (Block8Data* _data8_);
static void __dynamic_notebook_view___lambda8__granite_widgets_dynamic_notebook_new_tab_requested (GraniteWidgetsDynamicNotebook* _sender,
                                                                                            gpointer self);
static gboolean _dynamic_notebook_view___lambda9_ (DynamicNotebookView* self,
                                            GraniteWidgetsTab* tab);
static gboolean __dynamic_notebook_view___lambda9__granite_widgets_dynamic_notebook_close_tab_requested (GraniteWidgetsDynamicNotebook* _sender,
                                                                                                  GraniteWidgetsTab* tab,
                                                                                                  gpointer self);
static void _dynamic_notebook_view___lambda10_ (Block8Data* _data8_,
                                         const gchar* label,
                                         const gchar* data,
                                         GIcon* icon);
static void __dynamic_notebook_view___lambda10__granite_widgets_dynamic_notebook_tab_restored (GraniteWidgetsDynamicNotebook* _sender,
                                                                                        const gchar* label,
                                                                                        const gchar* data,
                                                                                        GIcon* icon,
                                                                                        gpointer self);
static GType dynamic_notebook_view_get_type_once (void);

DynamicNotebookView*
dynamic_notebook_view_construct (GType object_type)
{
	DynamicNotebookView * self = NULL;
	self = (DynamicNotebookView*) g_object_new (object_type, NULL);
	return self;
}

DynamicNotebookView*
dynamic_notebook_view_new (void)
{
	return dynamic_notebook_view_construct (TYPE_DYNAMIC_NOTEBOOK_VIEW);
}

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		DynamicNotebookView* self;
		self = _data8_->self;
		_g_object_unref0 (_data8_->notebook);
		_g_object_unref0 (self);
		g_slice_free (Block8Data, _data8_);
	}
}

static void
_dynamic_notebook_view___lambda8_ (Block8Data* _data8_)
{
	DynamicNotebookView* self;
	GtkLabel* page = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GraniteWidgetsTab* tab = NULL;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GThemedIcon* _tmp6_;
	GThemedIcon* _tmp7_;
	GtkLabel* _tmp8_;
	GraniteWidgetsTab* _tmp9_;
	GraniteWidgetsTab* _tmp10_;
	GraniteWidgetsTab* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GraniteWidgetsDynamicNotebook* _tmp14_;
	GraniteWidgetsTab* _tmp15_;
	gint _tmp16_;
	self = _data8_->self;
	_tmp0_ = g_strdup_printf ("Page %d", _data8_->i);
	_tmp1_ = _tmp0_;
	_tmp2_ = (GtkLabel*) gtk_label_new (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	page = _tmp3_;
	_tmp4_ = g_strdup_printf ("Tab %d", _data8_->i);
	_tmp5_ = _tmp4_;
	_tmp6_ = (GThemedIcon*) g_themed_icon_new ("mail-mark-important-symbolic");
	_tmp7_ = _tmp6_;
	_tmp8_ = page;
	_tmp9_ = granite_widgets_tab_new (_tmp5_, (GIcon*) _tmp7_, (GtkWidget*) _tmp8_);
	g_object_ref_sink (_tmp9_);
	_tmp10_ = _tmp9_;
	_g_object_unref0 (_tmp7_);
	_g_free0 (_tmp5_);
	tab = _tmp10_;
	_tmp11_ = tab;
	_tmp12_ = g_strdup_printf ("Customizable tooltip %d", _data8_->i);
	_tmp13_ = _tmp12_;
	granite_widgets_tab_set_tooltip (_tmp11_, _tmp13_);
	_g_free0 (_tmp13_);
	_tmp14_ = _data8_->notebook;
	_tmp15_ = tab;
	granite_widgets_dynamic_notebook_insert_tab (_tmp14_, _tmp15_, _data8_->i - 1);
	_tmp16_ = _data8_->i;
	_data8_->i = _tmp16_ + 1;
	_g_object_unref0 (tab);
	_g_object_unref0 (page);
}

static void
__dynamic_notebook_view___lambda8__granite_widgets_dynamic_notebook_new_tab_requested (GraniteWidgetsDynamicNotebook* _sender,
                                                                                       gpointer self)
{
	_dynamic_notebook_view___lambda8_ (self);
}

static gboolean
_dynamic_notebook_view___lambda9_ (DynamicNotebookView* self,
                                   GraniteWidgetsTab* tab)
{
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gboolean result;
	g_return_val_if_fail (tab != NULL, FALSE);
	_tmp0_ = granite_widgets_tab_get_page (tab);
	_tmp1_ = _tmp0_;
	_tmp2_ = gtk_label_get_label (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_label_get_type (), GtkLabel));
	_tmp3_ = _tmp2_;
	granite_widgets_tab_set_restore_data (tab, _tmp3_);
	result = TRUE;
	return result;
}

static gboolean
__dynamic_notebook_view___lambda9__granite_widgets_dynamic_notebook_close_tab_requested (GraniteWidgetsDynamicNotebook* _sender,
                                                                                         GraniteWidgetsTab* tab,
                                                                                         gpointer self)
{
	gboolean result;
	result = _dynamic_notebook_view___lambda9_ ((DynamicNotebookView*) self, tab);
	return result;
}

static void
_dynamic_notebook_view___lambda10_ (Block8Data* _data8_,
                                    const gchar* label,
                                    const gchar* data,
                                    GIcon* icon)
{
	DynamicNotebookView* self;
	GtkLabel* page = NULL;
	GtkLabel* _tmp0_;
	GraniteWidgetsTab* tab = NULL;
	GtkLabel* _tmp1_;
	GraniteWidgetsTab* _tmp2_;
	GraniteWidgetsDynamicNotebook* _tmp3_;
	GraniteWidgetsTab* _tmp4_;
	self = _data8_->self;
	g_return_if_fail (label != NULL);
	g_return_if_fail (data != NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (data);
	g_object_ref_sink (_tmp0_);
	page = _tmp0_;
	_tmp1_ = page;
	_tmp2_ = granite_widgets_tab_new (label, icon, (GtkWidget*) _tmp1_);
	g_object_ref_sink (_tmp2_);
	tab = _tmp2_;
	_tmp3_ = _data8_->notebook;
	_tmp4_ = tab;
	granite_widgets_dynamic_notebook_insert_tab (_tmp3_, _tmp4_, _data8_->i - 1);
	_g_object_unref0 (tab);
	_g_object_unref0 (page);
}

static void
__dynamic_notebook_view___lambda10__granite_widgets_dynamic_notebook_tab_restored (GraniteWidgetsDynamicNotebook* _sender,
                                                                                   const gchar* label,
                                                                                   const gchar* data,
                                                                                   GIcon* icon,
                                                                                   gpointer self)
{
	_dynamic_notebook_view___lambda10_ (self, label, data, icon);
}

static GObject *
dynamic_notebook_view_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DynamicNotebookView * self;
	Block8Data* _data8_;
	GraniteWidgetsDynamicNotebook* _tmp0_;
	GraniteWidgetsDynamicNotebook* _tmp1_;
	GraniteWidgetsDynamicNotebook* _tmp2_;
	GraniteWidgetsDynamicNotebook* _tmp21_;
	GraniteWidgetsDynamicNotebook* _tmp22_;
	GraniteWidgetsDynamicNotebook* _tmp23_;
	GraniteWidgetsDynamicNotebook* _tmp24_;
	parent_class = G_OBJECT_CLASS (dynamic_notebook_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DYNAMIC_NOTEBOOK_VIEW, DynamicNotebookView);
	_data8_ = g_slice_new0 (Block8Data);
	_data8_->_ref_count_ = 1;
	_data8_->self = g_object_ref (self);
	_tmp0_ = granite_widgets_dynamic_notebook_new ();
	g_object_ref_sink (_tmp0_);
	_data8_->notebook = _tmp0_;
	_tmp1_ = _data8_->notebook;
	g_object_set ((GtkWidget*) _tmp1_, "expand", TRUE, NULL);
	_tmp2_ = _data8_->notebook;
	granite_widgets_dynamic_notebook_set_allow_restoring (_tmp2_, TRUE);
	{
		gboolean _tmp3_ = FALSE;
		_data8_->i = 1;
		_tmp3_ = TRUE;
		while (TRUE) {
			GtkLabel* page = NULL;
			gchar* _tmp5_;
			gchar* _tmp6_;
			GtkLabel* _tmp7_;
			GtkLabel* _tmp8_;
			GraniteWidgetsTab* tab = NULL;
			gchar* _tmp9_;
			gchar* _tmp10_;
			GThemedIcon* _tmp11_;
			GThemedIcon* _tmp12_;
			GtkLabel* _tmp13_;
			GraniteWidgetsTab* _tmp14_;
			GraniteWidgetsTab* _tmp15_;
			GraniteWidgetsTab* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			GraniteWidgetsDynamicNotebook* _tmp19_;
			GraniteWidgetsTab* _tmp20_;
			if (!_tmp3_) {
				gint _tmp4_;
				_tmp4_ = _data8_->i;
				_data8_->i = _tmp4_ + 1;
			}
			_tmp3_ = FALSE;
			if (!(_data8_->i <= 6)) {
				break;
			}
			_tmp5_ = g_strdup_printf ("Page %d", _data8_->i);
			_tmp6_ = _tmp5_;
			_tmp7_ = (GtkLabel*) gtk_label_new (_tmp6_);
			g_object_ref_sink (_tmp7_);
			_tmp8_ = _tmp7_;
			_g_free0 (_tmp6_);
			page = _tmp8_;
			_tmp9_ = g_strdup_printf ("Tab %d", _data8_->i);
			_tmp10_ = _tmp9_;
			_tmp11_ = (GThemedIcon*) g_themed_icon_new ("mail-mark-important-symbolic");
			_tmp12_ = _tmp11_;
			_tmp13_ = page;
			_tmp14_ = granite_widgets_tab_new (_tmp10_, (GIcon*) _tmp12_, (GtkWidget*) _tmp13_);
			g_object_ref_sink (_tmp14_);
			_tmp15_ = _tmp14_;
			_g_object_unref0 (_tmp12_);
			_g_free0 (_tmp10_);
			tab = _tmp15_;
			_tmp16_ = tab;
			_tmp17_ = g_strdup_printf ("Customizable tooltip %d", _data8_->i);
			_tmp18_ = _tmp17_;
			granite_widgets_tab_set_tooltip (_tmp16_, _tmp18_);
			_g_free0 (_tmp18_);
			_tmp19_ = _data8_->notebook;
			_tmp20_ = tab;
			granite_widgets_dynamic_notebook_insert_tab (_tmp19_, _tmp20_, _data8_->i - 1);
			_g_object_unref0 (tab);
			_g_object_unref0 (page);
		}
	}
	_tmp21_ = _data8_->notebook;
	g_signal_connect_data (_tmp21_, "new-tab-requested", (GCallback) __dynamic_notebook_view___lambda8__granite_widgets_dynamic_notebook_new_tab_requested, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	_tmp22_ = _data8_->notebook;
	g_signal_connect_object (_tmp22_, "close-tab-requested", (GCallback) __dynamic_notebook_view___lambda9__granite_widgets_dynamic_notebook_close_tab_requested, self, 0);
	_tmp23_ = _data8_->notebook;
	g_signal_connect_data (_tmp23_, "tab-restored", (GCallback) __dynamic_notebook_view___lambda10__granite_widgets_dynamic_notebook_tab_restored, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	_tmp24_ = _data8_->notebook;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp24_);
	block8_data_unref (_data8_);
	_data8_ = NULL;
	return obj;
}

static void
dynamic_notebook_view_class_init (DynamicNotebookViewClass * klass,
                                  gpointer klass_data)
{
	dynamic_notebook_view_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = dynamic_notebook_view_constructor;
}

static void
dynamic_notebook_view_instance_init (DynamicNotebookView * self,
                                     gpointer klass)
{
}

static GType
dynamic_notebook_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DynamicNotebookViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dynamic_notebook_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DynamicNotebookView), 0, (GInstanceInitFunc) dynamic_notebook_view_instance_init, NULL };
	GType dynamic_notebook_view_type_id;
	dynamic_notebook_view_type_id = g_type_register_static (gtk_grid_get_type (), "DynamicNotebookView", &g_define_type_info, 0);
	return dynamic_notebook_view_type_id;
}

GType
dynamic_notebook_view_get_type (void)
{
	static volatile gsize dynamic_notebook_view_type_id__once = 0;
	if (g_once_init_enter (&dynamic_notebook_view_type_id__once)) {
		GType dynamic_notebook_view_type_id;
		dynamic_notebook_view_type_id = dynamic_notebook_view_get_type_once ();
		g_once_init_leave (&dynamic_notebook_view_type_id__once, dynamic_notebook_view_type_id);
	}
	return dynamic_notebook_view_type_id__once;
}

