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

/**/
/*  Copyright (C) 2014 Tom Beckmann*/
/**/
/*  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 <clutter/clutter.h>
#include <glib-object.h>
#include <meta/window.h>
#include <glib.h>
#include "gala.h"
#include <float.h>
#include <math.h>
#include <string.h>

#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 GALA_TYPE_WINDOW_ICON_ACTOR (gala_window_icon_actor_get_type ())
#define GALA_WINDOW_ICON_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_WINDOW_ICON_ACTOR, GalaWindowIconActor))
#define GALA_WINDOW_ICON_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_WINDOW_ICON_ACTOR, GalaWindowIconActorClass))
#define GALA_IS_WINDOW_ICON_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_WINDOW_ICON_ACTOR))
#define GALA_IS_WINDOW_ICON_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_WINDOW_ICON_ACTOR))
#define GALA_WINDOW_ICON_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_WINDOW_ICON_ACTOR, GalaWindowIconActorClass))

typedef struct _GalaWindowIconActor GalaWindowIconActor;
typedef struct _GalaWindowIconActorClass GalaWindowIconActorClass;
typedef struct _GalaWindowIconActorPrivate GalaWindowIconActorPrivate;
enum  {
	GALA_WINDOW_ICON_ACTOR_0_PROPERTY,
	GALA_WINDOW_ICON_ACTOR_WINDOW_PROPERTY,
	GALA_WINDOW_ICON_ACTOR_ICON_SIZE_PROPERTY,
	GALA_WINDOW_ICON_ACTOR_TEMPORARY_PROPERTY,
	GALA_WINDOW_ICON_ACTOR_NUM_PROPERTIES
};
static GParamSpec* gala_window_icon_actor_properties[GALA_WINDOW_ICON_ACTOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GalaWindowIconActor {
	ClutterActor parent_instance;
	GalaWindowIconActorPrivate * priv;
};

struct _GalaWindowIconActorClass {
	ClutterActorClass parent_class;
};

struct _GalaWindowIconActorPrivate {
	MetaWindow* _window;
	gint icon_scale;
	gint _icon_size;
	gboolean _temporary;
	gboolean initial;
	GalaWindowIcon* icon;
	GalaWindowIcon* old_icon;
};

static gint GalaWindowIconActor_private_offset;
static gpointer gala_window_icon_actor_parent_class = NULL;

VALA_EXTERN GType gala_window_icon_actor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaWindowIconActor, g_object_unref)
VALA_EXTERN MetaWindow* gala_window_icon_actor_get_window (GalaWindowIconActor* self);
static void gala_window_icon_actor_on_all_workspaces_changed (GalaWindowIconActor* self);
static void _gala_window_icon_actor_on_all_workspaces_changed_g_object_notify (GObject* _sender,
                                                                        GParamSpec* pspec,
                                                                        gpointer self);
VALA_EXTERN GalaWindowIconActor* gala_window_icon_actor_new (MetaWindow* window);
VALA_EXTERN GalaWindowIconActor* gala_window_icon_actor_construct (GType object_type,
                                                       MetaWindow* window);
VALA_EXTERN void gala_window_icon_actor_place (GalaWindowIconActor* self,
                                   gfloat x,
                                   gfloat y,
                                   gint size);
VALA_EXTERN void gala_window_icon_actor_set_icon_size (GalaWindowIconActor* self,
                                           gint value);
static void gala_window_icon_actor_fade_new_icon (GalaWindowIconActor* self);
VALA_EXTERN gint gala_internal_utils_get_ui_scaling_factor (void);
VALA_EXTERN gint gala_window_icon_actor_get_icon_size (GalaWindowIconActor* self);
static void ____lambda92_ (GalaWindowIconActor* self);
static void _____lambda92__clutter_timeline_completed (ClutterTimeline* _sender,
                                                gpointer self);
static void gala_window_icon_actor_set_window (GalaWindowIconActor* self,
                                        MetaWindow* value);
VALA_EXTERN gboolean gala_window_icon_actor_get_temporary (GalaWindowIconActor* self);
VALA_EXTERN void gala_window_icon_actor_set_temporary (GalaWindowIconActor* self,
                                           gboolean value);
static GObject * gala_window_icon_actor_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void gala_window_icon_actor_finalize (GObject * obj);
static GType gala_window_icon_actor_get_type_once (void);
static void _vala_gala_window_icon_actor_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_gala_window_icon_actor_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
gala_window_icon_actor_get_instance_private (GalaWindowIconActor* self)
{
	return G_STRUCT_MEMBER_P (self, GalaWindowIconActor_private_offset);
}

static void
_gala_window_icon_actor_on_all_workspaces_changed_g_object_notify (GObject* _sender,
                                                                   GParamSpec* pspec,
                                                                   gpointer self)
{
	gala_window_icon_actor_on_all_workspaces_changed ((GalaWindowIconActor*) self);
}

GalaWindowIconActor*
gala_window_icon_actor_construct (GType object_type,
                                  MetaWindow* window)
{
	GalaWindowIconActor * self = NULL;
	g_return_val_if_fail (window != NULL, NULL);
	self = (GalaWindowIconActor*) g_object_new (object_type, "window", window, NULL);
	return self;
}

GalaWindowIconActor*
gala_window_icon_actor_new (MetaWindow* window)
{
	return gala_window_icon_actor_construct (GALA_TYPE_WINDOW_ICON_ACTOR, window);
}

static void
gala_window_icon_actor_on_all_workspaces_changed (GalaWindowIconActor* self)
{
	MetaWindow* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_window;
	g_object_get (_tmp0_, "on-all-workspaces", &_tmp1_, NULL);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		clutter_actor_destroy ((ClutterActor*) self);
	}
}

/**
         * Shortcut to set both position and size of the icon
         *
         * @param x    The x coordinate to which to animate to
         * @param y    The y coordinate to which to animate to
         * @param size The size to which to animate to and display the icon in
         */
void
gala_window_icon_actor_place (GalaWindowIconActor* self,
                              gfloat x,
                              gfloat y,
                              gint size)
{
	g_return_if_fail (self != NULL);
	if (self->priv->initial) {
		clutter_actor_save_easing_state ((ClutterActor*) self);
		clutter_actor_set_easing_duration ((ClutterActor*) self, (guint) 10);
	}
	clutter_actor_set_position ((ClutterActor*) self, x, y);
	gala_window_icon_actor_set_icon_size (self, size);
	if (self->priv->initial) {
		clutter_actor_restore_easing_state ((ClutterActor*) self);
		self->priv->initial = FALSE;
	}
}

/**
         * Fades out the old icon and fades in the new icon
         */
static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
____lambda92_ (GalaWindowIconActor* self)
{
	GalaWindowIcon* _tmp0_;
	_tmp0_ = self->priv->old_icon;
	clutter_actor_destroy ((ClutterActor*) _tmp0_);
	_g_object_unref0 (self->priv->old_icon);
	self->priv->old_icon = NULL;
}

static void
_____lambda92__clutter_timeline_completed (ClutterTimeline* _sender,
                                           gpointer self)
{
	____lambda92_ ((GalaWindowIconActor*) self);
}

static void
gala_window_icon_actor_fade_new_icon (GalaWindowIconActor* self)
{
	gint scale = 0;
	GalaWindowIcon* new_icon = NULL;
	MetaWindow* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GalaWindowIcon* _tmp3_;
	GalaWindowIcon* _tmp4_;
	ClutterBindConstraint* _tmp5_;
	ClutterBindConstraint* _tmp6_;
	GalaWindowIcon* _tmp7_;
	GalaWindowIcon* _tmp8_;
	GalaWindowIcon* _tmp9_;
	GalaWindowIcon* _tmp10_;
	GalaWindowIcon* _tmp11_;
	GalaWindowIcon* _tmp16_;
	GalaWindowIcon* _tmp17_;
	GalaWindowIcon* _tmp25_;
	GalaWindowIcon* _tmp26_;
	g_return_if_fail (self != NULL);
	scale = gala_internal_utils_get_ui_scaling_factor ();
	_tmp0_ = self->priv->_window;
	_tmp1_ = gala_window_icon_actor_get_icon_size (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = gala_window_icon_new (_tmp0_, _tmp2_, scale, FALSE);
	g_object_ref_sink (_tmp3_);
	new_icon = _tmp3_;
	_tmp4_ = new_icon;
	_tmp5_ = (ClutterBindConstraint*) clutter_bind_constraint_new ((ClutterActor*) self, CLUTTER_BIND_SIZE, (gfloat) 0);
	g_object_ref_sink (_tmp5_);
	_tmp6_ = _tmp5_;
	clutter_actor_add_constraint ((ClutterActor*) _tmp4_, (ClutterConstraint*) _tmp6_);
	_g_object_unref0 (_tmp6_);
	_tmp7_ = new_icon;
	clutter_actor_set_opacity ((ClutterActor*) _tmp7_, (guint) 0);
	_tmp8_ = new_icon;
	clutter_actor_add_child ((ClutterActor*) self, (ClutterActor*) _tmp8_);
	_tmp9_ = new_icon;
	clutter_actor_set_easing_mode ((ClutterActor*) _tmp9_, CLUTTER_EASE_OUT_QUAD);
	_tmp10_ = new_icon;
	clutter_actor_set_easing_duration ((ClutterActor*) _tmp10_, (guint) 500);
	_tmp11_ = self->priv->icon;
	if (_tmp11_ == NULL) {
		GalaWindowIcon* _tmp12_;
		GalaWindowIcon* _tmp13_;
		_tmp12_ = new_icon;
		_tmp13_ = _g_object_ref0 (_tmp12_);
		_g_object_unref0 (self->priv->icon);
		self->priv->icon = _tmp13_;
	} else {
		GalaWindowIcon* _tmp14_;
		GalaWindowIcon* _tmp15_;
		_tmp14_ = self->priv->icon;
		_tmp15_ = _g_object_ref0 (_tmp14_);
		_g_object_unref0 (self->priv->old_icon);
		self->priv->old_icon = _tmp15_;
	}
	_tmp16_ = new_icon;
	clutter_actor_set_opacity ((ClutterActor*) _tmp16_, (guint) 255);
	_tmp17_ = self->priv->old_icon;
	if (_tmp17_ != NULL) {
		GalaWindowIcon* _tmp18_;
		ClutterTransition* transition = NULL;
		GalaWindowIcon* _tmp19_;
		ClutterTransition* _tmp20_;
		ClutterTransition* _tmp21_;
		ClutterTransition* _tmp22_;
		_tmp18_ = self->priv->old_icon;
		clutter_actor_set_opacity ((ClutterActor*) _tmp18_, (guint) 0);
		_tmp19_ = self->priv->old_icon;
		_tmp20_ = clutter_actor_get_transition ((ClutterActor*) _tmp19_, "opacity");
		_tmp21_ = _g_object_ref0 (_tmp20_);
		transition = _tmp21_;
		_tmp22_ = transition;
		if (_tmp22_ != NULL) {
			ClutterTransition* _tmp23_;
			_tmp23_ = transition;
			g_signal_connect_object ((ClutterTimeline*) _tmp23_, "completed", (GCallback) _____lambda92__clutter_timeline_completed, self, 0);
		} else {
			GalaWindowIcon* _tmp24_;
			_tmp24_ = self->priv->old_icon;
			clutter_actor_destroy ((ClutterActor*) _tmp24_);
			_g_object_unref0 (self->priv->old_icon);
			self->priv->old_icon = NULL;
		}
		_g_object_unref0 (transition);
	}
	_tmp25_ = new_icon;
	_tmp26_ = _g_object_ref0 (_tmp25_);
	_g_object_unref0 (self->priv->icon);
	self->priv->icon = _tmp26_;
	_g_object_unref0 (new_icon);
}

MetaWindow*
gala_window_icon_actor_get_window (GalaWindowIconActor* self)
{
	MetaWindow* result;
	MetaWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

static void
gala_window_icon_actor_set_window (GalaWindowIconActor* self,
                                   MetaWindow* value)
{
	MetaWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_window_icon_actor_get_window (self);
	if (old_value != value) {
		MetaWindow* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_window);
		self->priv->_window = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_window_icon_actor_properties[GALA_WINDOW_ICON_ACTOR_WINDOW_PROPERTY]);
	}
}

gint
gala_window_icon_actor_get_icon_size (GalaWindowIconActor* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_icon_size;
	return result;
}

void
gala_window_icon_actor_set_icon_size (GalaWindowIconActor* self,
                                      gint value)
{
	gint scale = 0;
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	scale = gala_internal_utils_get_ui_scaling_factor ();
	if (value == self->priv->_icon_size) {
		_tmp0_ = scale == self->priv->icon_scale;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	self->priv->_icon_size = value;
	self->priv->icon_scale = scale;
	clutter_actor_set_size ((ClutterActor*) self, (gfloat) (self->priv->_icon_size * scale), (gfloat) (self->priv->_icon_size * scale));
	gala_window_icon_actor_fade_new_icon (self);
	g_object_notify_by_pspec ((GObject *) self, gala_window_icon_actor_properties[GALA_WINDOW_ICON_ACTOR_ICON_SIZE_PROPERTY]);
}

gboolean
gala_window_icon_actor_get_temporary (GalaWindowIconActor* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_temporary;
	return result;
}

void
gala_window_icon_actor_set_temporary (GalaWindowIconActor* self,
                                      gboolean value)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	if (self->priv->_temporary) {
		_tmp0_ = !value;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		clutter_actor_remove_transition ((ClutterActor*) self, "pulse");
	} else {
		gboolean _tmp1_ = FALSE;
		if (!self->priv->_temporary) {
			_tmp1_ = value;
		} else {
			_tmp1_ = FALSE;
		}
		if (_tmp1_) {
			ClutterTransitionGroup* transition = NULL;
			ClutterTransitionGroup* _tmp2_ = NULL;
			ClutterPropertyTransition* opacity_transition = NULL;
			ClutterPropertyTransition* _tmp3_;
			ClutterPropertyTransition* _tmp4_;
			GValue _tmp5_ = {0};
			ClutterPropertyTransition* _tmp6_;
			GValue _tmp7_ = {0};
			ClutterPropertyTransition* _tmp8_;
			ClutterPropertyTransition* scale_x_transition = NULL;
			ClutterPropertyTransition* _tmp9_;
			ClutterPropertyTransition* _tmp10_;
			GValue _tmp11_ = {0};
			ClutterPropertyTransition* _tmp12_;
			GValue _tmp13_ = {0};
			ClutterPropertyTransition* _tmp14_;
			ClutterPropertyTransition* scale_y_transition = NULL;
			ClutterPropertyTransition* _tmp15_;
			ClutterPropertyTransition* _tmp16_;
			GValue _tmp17_ = {0};
			ClutterPropertyTransition* _tmp18_;
			GValue _tmp19_ = {0};
			ClutterPropertyTransition* _tmp20_;
			ClutterTransitionGroup* _tmp21_;
			ClutterPropertyTransition* _tmp22_;
			ClutterTransitionGroup* _tmp23_;
			ClutterPropertyTransition* _tmp24_;
			ClutterTransitionGroup* _tmp25_;
			ClutterPropertyTransition* _tmp26_;
			ClutterTransitionGroup* _tmp27_;
			_tmp2_ = (ClutterTransitionGroup*) clutter_transition_group_new ();
			clutter_timeline_set_duration ((ClutterTimeline*) _tmp2_, (guint) 800);
			clutter_timeline_set_auto_reverse ((ClutterTimeline*) _tmp2_, TRUE);
			clutter_timeline_set_repeat_count ((ClutterTimeline*) _tmp2_, -1);
			clutter_timeline_set_progress_mode ((ClutterTimeline*) _tmp2_, CLUTTER_LINEAR);
			transition = _tmp2_;
			_tmp3_ = (ClutterPropertyTransition*) clutter_property_transition_new ("opacity");
			opacity_transition = _tmp3_;
			_tmp4_ = opacity_transition;
			g_value_init (&_tmp5_, G_TYPE_INT);
			g_value_set_int (&_tmp5_, 100);
			clutter_transition_set_from_value ((ClutterTransition*) _tmp4_, &_tmp5_);
			G_IS_VALUE (&_tmp5_) ? (g_value_unset (&_tmp5_), NULL) : NULL;
			_tmp6_ = opacity_transition;
			g_value_init (&_tmp7_, G_TYPE_INT);
			g_value_set_int (&_tmp7_, 255);
			clutter_transition_set_to_value ((ClutterTransition*) _tmp6_, &_tmp7_);
			G_IS_VALUE (&_tmp7_) ? (g_value_unset (&_tmp7_), NULL) : NULL;
			_tmp8_ = opacity_transition;
			clutter_timeline_set_auto_reverse ((ClutterTimeline*) _tmp8_, TRUE);
			_tmp9_ = (ClutterPropertyTransition*) clutter_property_transition_new ("scale-x");
			scale_x_transition = _tmp9_;
			_tmp10_ = scale_x_transition;
			g_value_init (&_tmp11_, G_TYPE_DOUBLE);
			g_value_set_double (&_tmp11_, 0.8);
			clutter_transition_set_from_value ((ClutterTransition*) _tmp10_, &_tmp11_);
			G_IS_VALUE (&_tmp11_) ? (g_value_unset (&_tmp11_), NULL) : NULL;
			_tmp12_ = scale_x_transition;
			g_value_init (&_tmp13_, G_TYPE_DOUBLE);
			g_value_set_double (&_tmp13_, 1.1);
			clutter_transition_set_to_value ((ClutterTransition*) _tmp12_, &_tmp13_);
			G_IS_VALUE (&_tmp13_) ? (g_value_unset (&_tmp13_), NULL) : NULL;
			_tmp14_ = scale_x_transition;
			clutter_timeline_set_auto_reverse ((ClutterTimeline*) _tmp14_, TRUE);
			_tmp15_ = (ClutterPropertyTransition*) clutter_property_transition_new ("scale-y");
			scale_y_transition = _tmp15_;
			_tmp16_ = scale_y_transition;
			g_value_init (&_tmp17_, G_TYPE_DOUBLE);
			g_value_set_double (&_tmp17_, 0.8);
			clutter_transition_set_from_value ((ClutterTransition*) _tmp16_, &_tmp17_);
			G_IS_VALUE (&_tmp17_) ? (g_value_unset (&_tmp17_), NULL) : NULL;
			_tmp18_ = scale_y_transition;
			g_value_init (&_tmp19_, G_TYPE_DOUBLE);
			g_value_set_double (&_tmp19_, 1.1);
			clutter_transition_set_to_value ((ClutterTransition*) _tmp18_, &_tmp19_);
			G_IS_VALUE (&_tmp19_) ? (g_value_unset (&_tmp19_), NULL) : NULL;
			_tmp20_ = scale_y_transition;
			clutter_timeline_set_auto_reverse ((ClutterTimeline*) _tmp20_, TRUE);
			_tmp21_ = transition;
			_tmp22_ = opacity_transition;
			clutter_transition_group_add_transition (_tmp21_, (ClutterTransition*) _tmp22_);
			_tmp23_ = transition;
			_tmp24_ = scale_x_transition;
			clutter_transition_group_add_transition (_tmp23_, (ClutterTransition*) _tmp24_);
			_tmp25_ = transition;
			_tmp26_ = scale_y_transition;
			clutter_transition_group_add_transition (_tmp25_, (ClutterTransition*) _tmp26_);
			_tmp27_ = transition;
			clutter_actor_add_transition ((ClutterActor*) self, "pulse", (ClutterTransition*) _tmp27_);
			_g_object_unref0 (scale_y_transition);
			_g_object_unref0 (scale_x_transition);
			_g_object_unref0 (opacity_transition);
			_g_object_unref0 (transition);
		}
	}
	self->priv->_temporary = value;
	g_object_notify_by_pspec ((GObject *) self, gala_window_icon_actor_properties[GALA_WINDOW_ICON_ACTOR_TEMPORARY_PROPERTY]);
}

static GObject *
gala_window_icon_actor_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaWindowIconActor * self;
	MetaWindow* _tmp0_;
	parent_class = G_OBJECT_CLASS (gala_window_icon_actor_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_WINDOW_ICON_ACTOR, GalaWindowIconActor);
	clutter_actor_set_pivot_point ((ClutterActor*) self, 0.5f, 0.5f);
	clutter_actor_set_easing_mode ((ClutterActor*) self, CLUTTER_EASE_OUT_ELASTIC);
	clutter_actor_set_easing_duration ((ClutterActor*) self, (guint) 800);
	_tmp0_ = self->priv->_window;
	g_signal_connect_object ((GObject*) _tmp0_, "notify::on-all-workspaces", (GCallback) _gala_window_icon_actor_on_all_workspaces_changed_g_object_notify, self, 0);
	self->priv->icon_scale = gala_internal_utils_get_ui_scaling_factor ();
	return obj;
}

static void
gala_window_icon_actor_class_init (GalaWindowIconActorClass * klass,
                                   gpointer klass_data)
{
	gala_window_icon_actor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaWindowIconActor_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_window_icon_actor_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_window_icon_actor_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_window_icon_actor_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_window_icon_actor_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_WINDOW_ICON_ACTOR_WINDOW_PROPERTY, gala_window_icon_actor_properties[GALA_WINDOW_ICON_ACTOR_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", meta_window_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	/**
	         * The icon size of the WindowIcon. Once set the new icon will be
	         * faded over the old one and the actor animates to the new size.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_WINDOW_ICON_ACTOR_ICON_SIZE_PROPERTY, gala_window_icon_actor_properties[GALA_WINDOW_ICON_ACTOR_ICON_SIZE_PROPERTY] = g_param_spec_int ("icon-size", "icon-size", "icon-size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	         * Mark the WindowIcon as temporary. Only effect of this is that a pulse
	         * animation will be played on the actor. Used while DnDing window thumbs
	         * over the group.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_WINDOW_ICON_ACTOR_TEMPORARY_PROPERTY, gala_window_icon_actor_properties[GALA_WINDOW_ICON_ACTOR_TEMPORARY_PROPERTY] = g_param_spec_boolean ("temporary", "temporary", "temporary", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
gala_window_icon_actor_instance_init (GalaWindowIconActor * self,
                                      gpointer klass)
{
	self->priv = gala_window_icon_actor_get_instance_private (self);
	self->priv->initial = TRUE;
	self->priv->icon = NULL;
	self->priv->old_icon = NULL;
}

static void
gala_window_icon_actor_finalize (GObject * obj)
{
	GalaWindowIconActor * self;
	MetaWindow* _tmp0_;
	guint _tmp1_;
	GQuark _tmp2_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_WINDOW_ICON_ACTOR, GalaWindowIconActor);
	_tmp0_ = self->priv->_window;
	g_signal_parse_name ("notify::on-all-workspaces", G_TYPE_OBJECT, &_tmp1_, &_tmp2_, TRUE);
	g_signal_handlers_disconnect_matched ((GObject*) _tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, _tmp2_, NULL, (GCallback) _gala_window_icon_actor_on_all_workspaces_changed_g_object_notify, self);
	_g_object_unref0 (self->priv->_window);
	_g_object_unref0 (self->priv->icon);
	_g_object_unref0 (self->priv->old_icon);
	G_OBJECT_CLASS (gala_window_icon_actor_parent_class)->finalize (obj);
}

/**
     * Private class which is basically just a container for the actual
     * icon and takes care of blending the same icon in different sizes
     * over each other and various animations related to the icons
     */
static GType
gala_window_icon_actor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaWindowIconActorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_window_icon_actor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaWindowIconActor), 0, (GInstanceInitFunc) gala_window_icon_actor_instance_init, NULL };
	GType gala_window_icon_actor_type_id;
	gala_window_icon_actor_type_id = g_type_register_static (clutter_actor_get_type (), "GalaWindowIconActor", &g_define_type_info, 0);
	GalaWindowIconActor_private_offset = g_type_add_instance_private (gala_window_icon_actor_type_id, sizeof (GalaWindowIconActorPrivate));
	return gala_window_icon_actor_type_id;
}

GType
gala_window_icon_actor_get_type (void)
{
	static volatile gsize gala_window_icon_actor_type_id__once = 0;
	if (g_once_init_enter (&gala_window_icon_actor_type_id__once)) {
		GType gala_window_icon_actor_type_id;
		gala_window_icon_actor_type_id = gala_window_icon_actor_get_type_once ();
		g_once_init_leave (&gala_window_icon_actor_type_id__once, gala_window_icon_actor_type_id);
	}
	return gala_window_icon_actor_type_id__once;
}

static void
_vala_gala_window_icon_actor_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	GalaWindowIconActor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_WINDOW_ICON_ACTOR, GalaWindowIconActor);
	switch (property_id) {
		case GALA_WINDOW_ICON_ACTOR_WINDOW_PROPERTY:
		g_value_set_object (value, gala_window_icon_actor_get_window (self));
		break;
		case GALA_WINDOW_ICON_ACTOR_ICON_SIZE_PROPERTY:
		g_value_set_int (value, gala_window_icon_actor_get_icon_size (self));
		break;
		case GALA_WINDOW_ICON_ACTOR_TEMPORARY_PROPERTY:
		g_value_set_boolean (value, gala_window_icon_actor_get_temporary (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_window_icon_actor_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	GalaWindowIconActor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_WINDOW_ICON_ACTOR, GalaWindowIconActor);
	switch (property_id) {
		case GALA_WINDOW_ICON_ACTOR_WINDOW_PROPERTY:
		gala_window_icon_actor_set_window (self, g_value_get_object (value));
		break;
		case GALA_WINDOW_ICON_ACTOR_ICON_SIZE_PROPERTY:
		gala_window_icon_actor_set_icon_size (self, g_value_get_int (value));
		break;
		case GALA_WINDOW_ICON_ACTOR_TEMPORARY_PROPERTY:
		gala_window_icon_actor_set_temporary (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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;
}

