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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*-
 *
 * Copyright (C) 2011,2012 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * 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/>.
 *
 * Authored by: Michael Terry <michael.terry@canonical.com>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <cairo-gobject.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <string.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_FADABLE (fadable_get_type ())
#define FADABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FADABLE, Fadable))
#define IS_FADABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FADABLE))
#define FADABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_FADABLE, FadableIface))

typedef struct _Fadable Fadable;
typedef struct _FadableIface FadableIface;

#define TYPE_FADE_TRACKER (fade_tracker_get_type ())
#define FADE_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FADE_TRACKER, FadeTracker))
#define FADE_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FADE_TRACKER, FadeTrackerClass))
#define IS_FADE_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FADE_TRACKER))
#define IS_FADE_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FADE_TRACKER))
#define FADE_TRACKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FADE_TRACKER, FadeTrackerClass))

typedef struct _FadeTracker FadeTracker;
typedef struct _FadeTrackerClass FadeTrackerClass;

#define TYPE_FADABLE_BOX (fadable_box_get_type ())
#define FADABLE_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FADABLE_BOX, FadableBox))
#define FADABLE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FADABLE_BOX, FadableBoxClass))
#define IS_FADABLE_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FADABLE_BOX))
#define IS_FADABLE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FADABLE_BOX))
#define FADABLE_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FADABLE_BOX, FadableBoxClass))

typedef struct _FadableBox FadableBox;
typedef struct _FadableBoxClass FadableBoxClass;
typedef struct _FadableBoxPrivate FadableBoxPrivate;
enum  {
	FADABLE_BOX_0_PROPERTY,
	FADABLE_BOX_FADE_TRACKER_PROPERTY,
	FADABLE_BOX_NUM_PROPERTIES
};
static GParamSpec* fadable_box_properties[FADABLE_BOX_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	FADABLE_BOX_FADE_DONE_SIGNAL,
	FADABLE_BOX_NUM_SIGNALS
};
static guint fadable_box_signals[FADABLE_BOX_NUM_SIGNALS] = {0};

struct _FadableIface {
	GTypeInterface parent_iface;
	FadeTracker* (*get_fade_tracker) (Fadable* self);
	void (*set_fade_tracker) (Fadable* self, FadeTracker* value);
};

struct _FadableBox {
	GtkEventBox parent_instance;
	FadableBoxPrivate * priv;
};

struct _FadableBoxClass {
	GtkEventBoxClass parent_class;
	void (*draw_full_alpha) (FadableBox* self, cairo_t* c);
};

struct _FadableBoxPrivate {
	FadeTracker* _fade_tracker;
};

static gint FadableBox_private_offset;
static gpointer fadable_box_parent_class = NULL;
static FadableIface * fadable_box_fadable_parent_iface = NULL;

VALA_EXTERN GType fade_tracker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FadeTracker, g_object_unref)
VALA_EXTERN GType fadable_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Fadable, g_object_unref)
VALA_EXTERN GType fadable_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FadableBox, g_object_unref)
VALA_EXTERN void fadable_box_draw_full_alpha (FadableBox* self,
                                  cairo_t* c);
static void fadable_box_real_draw_full_alpha (FadableBox* self,
                                       cairo_t* c);
static gboolean fadable_box_real_draw (GtkWidget* base,
                                cairo_t* c);
VALA_EXTERN FadeTracker* fadable_get_fade_tracker (Fadable* self);
VALA_EXTERN gdouble fade_tracker_get_alpha (FadeTracker* self);
VALA_EXTERN FadableBox* fadable_box_new (void);
VALA_EXTERN FadableBox* fadable_box_construct (GType object_type);
static GObject * fadable_box_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties);
VALA_EXTERN FadeTracker* fade_tracker_new (GtkWidget* widget);
VALA_EXTERN FadeTracker* fade_tracker_construct (GType object_type,
                                     GtkWidget* widget);
VALA_EXTERN void fadable_set_fade_tracker (Fadable* self,
                               FadeTracker* value);
static void _fadable_box___lambda23_ (FadableBox* self);
static void __fadable_box___lambda23__fade_tracker_done (FadeTracker* _sender,
                                                  gpointer self);
static void fadable_box_finalize (GObject * obj);
static GType fadable_box_get_type_once (void);
static void _vala_fadable_box_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_fadable_box_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
fadable_box_get_instance_private (FadableBox* self)
{
	return G_STRUCT_MEMBER_P (self, FadableBox_private_offset);
}

static void
fadable_box_real_draw_full_alpha (FadableBox* self,
                                  cairo_t* c)
{
#line 33 "../src/fadable-box.vala"
	g_return_if_fail (c != NULL);
#line 35 "../src/fadable-box.vala"
	GTK_WIDGET_CLASS (fadable_box_parent_class)->draw ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_event_box_get_type (), GtkEventBox), c);
#line 169 "fadable-box.c"
}

void
fadable_box_draw_full_alpha (FadableBox* self,
                             cairo_t* c)
{
	FadableBoxClass* _klass_;
#line 33 "../src/fadable-box.vala"
	g_return_if_fail (self != NULL);
#line 33 "../src/fadable-box.vala"
	_klass_ = FADABLE_BOX_GET_CLASS (self);
#line 33 "../src/fadable-box.vala"
	if (_klass_->draw_full_alpha) {
#line 33 "../src/fadable-box.vala"
		_klass_->draw_full_alpha (self, c);
#line 185 "fadable-box.c"
	}
}

static gboolean
fadable_box_real_draw (GtkWidget* base,
                       cairo_t* c)
{
	FadableBox * self;
	FadeTracker* _tmp0_;
	FadeTracker* _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	gboolean result;
#line 38 "../src/fadable-box.vala"
	self = (FadableBox*) base;
#line 38 "../src/fadable-box.vala"
	g_return_val_if_fail (c != NULL, FALSE);
#line 40 "../src/fadable-box.vala"
	cairo_push_group (c);
#line 41 "../src/fadable-box.vala"
	fadable_box_draw_full_alpha (self, c);
#line 42 "../src/fadable-box.vala"
	cairo_pop_group_to_source (c);
#line 43 "../src/fadable-box.vala"
	_tmp0_ = fadable_get_fade_tracker ((Fadable*) self);
#line 43 "../src/fadable-box.vala"
	_tmp1_ = _tmp0_;
#line 43 "../src/fadable-box.vala"
	_tmp2_ = fade_tracker_get_alpha (_tmp1_);
#line 43 "../src/fadable-box.vala"
	_tmp3_ = _tmp2_;
#line 43 "../src/fadable-box.vala"
	cairo_paint_with_alpha (c, _tmp3_);
#line 44 "../src/fadable-box.vala"
	result = FALSE;
#line 44 "../src/fadable-box.vala"
	return result;
#line 223 "fadable-box.c"
}

FadableBox*
fadable_box_construct (GType object_type)
{
	FadableBox * self = NULL;
#line 20 "../src/fadable-box.vala"
	self = (FadableBox*) g_object_new (object_type, NULL);
#line 20 "../src/fadable-box.vala"
	return self;
#line 234 "fadable-box.c"
}

FadableBox*
fadable_box_new (void)
{
#line 20 "../src/fadable-box.vala"
	return fadable_box_construct (TYPE_FADABLE_BOX);
#line 242 "fadable-box.c"
}

static FadeTracker*
fadable_box_real_get_fade_tracker (Fadable* base)
{
	FadeTracker* result;
	FadableBox* self;
	FadeTracker* _tmp0_;
#line 24 "../src/fadable-box.vala"
	self = (FadableBox*) base;
#line 24 "../src/fadable-box.vala"
	_tmp0_ = self->priv->_fade_tracker;
#line 24 "../src/fadable-box.vala"
	result = _tmp0_;
#line 24 "../src/fadable-box.vala"
	return result;
#line 259 "fadable-box.c"
}

static gpointer
_g_object_ref0 (gpointer self)
{
#line 24 "../src/fadable-box.vala"
	return self ? g_object_ref (self) : NULL;
#line 267 "fadable-box.c"
}

static void
fadable_box_real_set_fade_tracker (Fadable* base,
                                   FadeTracker* value)
{
	FadableBox* self;
	FadeTracker* old_value;
#line 24 "../src/fadable-box.vala"
	self = (FadableBox*) base;
#line 24 "../src/fadable-box.vala"
	old_value = fadable_box_real_get_fade_tracker (base);
#line 24 "../src/fadable-box.vala"
	if (old_value != value) {
#line 282 "fadable-box.c"
		FadeTracker* _tmp0_;
#line 24 "../src/fadable-box.vala"
		_tmp0_ = _g_object_ref0 (value);
#line 24 "../src/fadable-box.vala"
		_g_object_unref0 (self->priv->_fade_tracker);
#line 24 "../src/fadable-box.vala"
		self->priv->_fade_tracker = _tmp0_;
#line 24 "../src/fadable-box.vala"
		g_object_notify_by_pspec ((GObject *) self, fadable_box_properties[FADABLE_BOX_FADE_TRACKER_PROPERTY]);
#line 292 "fadable-box.c"
	}
}

static void
_fadable_box___lambda23_ (FadableBox* self)
{
#line 30 "../src/fadable-box.vala"
	g_signal_emit (self, fadable_box_signals[FADABLE_BOX_FADE_DONE_SIGNAL], 0);
#line 301 "fadable-box.c"
}

static void
__fadable_box___lambda23__fade_tracker_done (FadeTracker* _sender,
                                             gpointer self)
{
#line 30 "../src/fadable-box.vala"
	_fadable_box___lambda23_ ((FadableBox*) self);
#line 310 "fadable-box.c"
}

static GObject *
fadable_box_constructor (GType type,
                         guint n_construct_properties,
                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FadableBox * self;
	FadeTracker* _tmp0_;
	FadeTracker* _tmp1_;
	FadeTracker* _tmp2_;
	FadeTracker* _tmp3_;
#line 26 "../src/fadable-box.vala"
	parent_class = G_OBJECT_CLASS (fadable_box_parent_class);
#line 26 "../src/fadable-box.vala"
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
#line 26 "../src/fadable-box.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FADABLE_BOX, FadableBox);
#line 28 "../src/fadable-box.vala"
	gtk_event_box_set_visible_window ((GtkEventBox*) self, FALSE);
#line 29 "../src/fadable-box.vala"
	_tmp0_ = fade_tracker_new ((GtkWidget*) self);
#line 29 "../src/fadable-box.vala"
	_tmp1_ = _tmp0_;
#line 29 "../src/fadable-box.vala"
	fadable_set_fade_tracker ((Fadable*) self, _tmp1_);
#line 29 "../src/fadable-box.vala"
	_g_object_unref0 (_tmp1_);
#line 30 "../src/fadable-box.vala"
	_tmp2_ = fadable_get_fade_tracker ((Fadable*) self);
#line 30 "../src/fadable-box.vala"
	_tmp3_ = _tmp2_;
#line 30 "../src/fadable-box.vala"
	g_signal_connect_object (_tmp3_, "done", (GCallback) __fadable_box___lambda23__fade_tracker_done, self, 0);
#line 26 "../src/fadable-box.vala"
	return obj;
#line 349 "fadable-box.c"
}

static void
fadable_box_class_init (FadableBoxClass * klass,
                        gpointer klass_data)
{
#line 20 "../src/fadable-box.vala"
	fadable_box_parent_class = g_type_class_peek_parent (klass);
#line 20 "../src/fadable-box.vala"
	g_type_class_adjust_private_offset (klass, &FadableBox_private_offset);
#line 20 "../src/fadable-box.vala"
	((FadableBoxClass *) klass)->draw_full_alpha = (void (*) (FadableBox*, cairo_t*)) fadable_box_real_draw_full_alpha;
#line 20 "../src/fadable-box.vala"
	((GtkWidgetClass *) klass)->draw = (gboolean (*) (GtkWidget*, cairo_t*)) fadable_box_real_draw;
#line 20 "../src/fadable-box.vala"
	G_OBJECT_CLASS (klass)->get_property = _vala_fadable_box_get_property;
#line 20 "../src/fadable-box.vala"
	G_OBJECT_CLASS (klass)->set_property = _vala_fadable_box_set_property;
#line 20 "../src/fadable-box.vala"
	G_OBJECT_CLASS (klass)->constructor = fadable_box_constructor;
#line 20 "../src/fadable-box.vala"
	G_OBJECT_CLASS (klass)->finalize = fadable_box_finalize;
#line 20 "../src/fadable-box.vala"
	g_object_class_install_property (G_OBJECT_CLASS (klass), FADABLE_BOX_FADE_TRACKER_PROPERTY, fadable_box_properties[FADABLE_BOX_FADE_TRACKER_PROPERTY] = g_param_spec_object ("fade-tracker", "fade-tracker", "fade-tracker", TYPE_FADE_TRACKER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
#line 20 "../src/fadable-box.vala"
	fadable_box_signals[FADABLE_BOX_FADE_DONE_SIGNAL] = g_signal_new ("fade-done", TYPE_FADABLE_BOX, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
#line 376 "fadable-box.c"
}

static void
fadable_box_fadable_interface_init (FadableIface * iface,
                                    gpointer iface_data)
{
#line 20 "../src/fadable-box.vala"
	fadable_box_fadable_parent_iface = g_type_interface_peek_parent (iface);
#line 20 "../src/fadable-box.vala"
	iface->get_fade_tracker = fadable_box_real_get_fade_tracker;
#line 20 "../src/fadable-box.vala"
	iface->set_fade_tracker = fadable_box_real_set_fade_tracker;
#line 389 "fadable-box.c"
}

static void
fadable_box_instance_init (FadableBox * self,
                           gpointer klass)
{
#line 20 "../src/fadable-box.vala"
	self->priv = fadable_box_get_instance_private (self);
#line 398 "fadable-box.c"
}

static void
fadable_box_finalize (GObject * obj)
{
	FadableBox * self;
#line 20 "../src/fadable-box.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FADABLE_BOX, FadableBox);
#line 24 "../src/fadable-box.vala"
	_g_object_unref0 (self->priv->_fade_tracker);
#line 20 "../src/fadable-box.vala"
	G_OBJECT_CLASS (fadable_box_parent_class)->finalize (obj);
#line 411 "fadable-box.c"
}

static GType
fadable_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FadableBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) fadable_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FadableBox), 0, (GInstanceInitFunc) fadable_box_instance_init, NULL };
	static const GInterfaceInfo fadable_info = { (GInterfaceInitFunc) fadable_box_fadable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType fadable_box_type_id;
	fadable_box_type_id = g_type_register_static (gtk_event_box_get_type (), "FadableBox", &g_define_type_info, 0);
	g_type_add_interface_static (fadable_box_type_id, TYPE_FADABLE, &fadable_info);
	FadableBox_private_offset = g_type_add_instance_private (fadable_box_type_id, sizeof (FadableBoxPrivate));
	return fadable_box_type_id;
}

GType
fadable_box_get_type (void)
{
	static volatile gsize fadable_box_type_id__once = 0;
	if (g_once_init_enter (&fadable_box_type_id__once)) {
		GType fadable_box_type_id;
		fadable_box_type_id = fadable_box_get_type_once ();
		g_once_init_leave (&fadable_box_type_id__once, fadable_box_type_id);
	}
	return fadable_box_type_id__once;
}

static void
_vala_fadable_box_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	FadableBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FADABLE_BOX, FadableBox);
#line 20 "../src/fadable-box.vala"
	switch (property_id) {
#line 20 "../src/fadable-box.vala"
		case FADABLE_BOX_FADE_TRACKER_PROPERTY:
#line 20 "../src/fadable-box.vala"
		g_value_set_object (value, fadable_get_fade_tracker ((Fadable*) self));
#line 20 "../src/fadable-box.vala"
		break;
#line 454 "fadable-box.c"
		default:
#line 20 "../src/fadable-box.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 20 "../src/fadable-box.vala"
		break;
#line 460 "fadable-box.c"
	}
}

static void
_vala_fadable_box_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	FadableBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FADABLE_BOX, FadableBox);
#line 20 "../src/fadable-box.vala"
	switch (property_id) {
#line 20 "../src/fadable-box.vala"
		case FADABLE_BOX_FADE_TRACKER_PROPERTY:
#line 20 "../src/fadable-box.vala"
		fadable_set_fade_tracker ((Fadable*) self, g_value_get_object (value));
#line 20 "../src/fadable-box.vala"
		break;
#line 480 "fadable-box.c"
		default:
#line 20 "../src/fadable-box.vala"
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
#line 20 "../src/fadable-box.vala"
		break;
#line 486 "fadable-box.c"
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

