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

/*
 * This file is part of budgie-desktop.
 *
 * Copyright (C) 2015-2016 Ikey Doherty <ikey@solus-project.com>
 *
 * This library 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.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>


#define BUDGIE_TYPE_SHADOW_BLOCK (budgie_shadow_block_get_type ())
#define BUDGIE_SHADOW_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BUDGIE_TYPE_SHADOW_BLOCK, BudgieShadowBlock))
#define BUDGIE_SHADOW_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BUDGIE_TYPE_SHADOW_BLOCK, BudgieShadowBlockClass))
#define BUDGIE_IS_SHADOW_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BUDGIE_TYPE_SHADOW_BLOCK))
#define BUDGIE_IS_SHADOW_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BUDGIE_TYPE_SHADOW_BLOCK))
#define BUDGIE_SHADOW_BLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BUDGIE_TYPE_SHADOW_BLOCK, BudgieShadowBlockClass))

typedef struct _BudgieShadowBlock BudgieShadowBlock;
typedef struct _BudgieShadowBlockClass BudgieShadowBlockClass;
typedef struct _BudgieShadowBlockPrivate BudgieShadowBlockPrivate;

#define BUDGIE_TYPE_PANEL_POSITION (budgie_panel_position_get_type ())

struct _BudgieShadowBlock {
	GtkEventBox parent_instance;
	BudgieShadowBlockPrivate * priv;
};

struct _BudgieShadowBlockClass {
	GtkEventBoxClass parent_class;
};

typedef enum  {
	BUDGIE_PANEL_POSITION_NONE = 1 << 0,
	BUDGIE_PANEL_POSITION_BOTTOM = 1 << 1,
	BUDGIE_PANEL_POSITION_TOP = 1 << 2,
	BUDGIE_PANEL_POSITION_LEFT = 1 << 3,
	BUDGIE_PANEL_POSITION_RIGHT = 1 << 4
} BudgiePanelPosition;

struct _BudgieShadowBlockPrivate {
	gint size;
	BudgiePanelPosition pos;
	gboolean horizontal;
	gint rm;
};


static gpointer budgie_shadow_block_parent_class = NULL;

GType budgie_shadow_block_get_type (void) G_GNUC_CONST;
GType budgie_panel_position_get_type (void) G_GNUC_CONST;
#define BUDGIE_SHADOW_BLOCK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BUDGIE_TYPE_SHADOW_BLOCK, BudgieShadowBlockPrivate))
enum  {
	BUDGIE_SHADOW_BLOCK_DUMMY_PROPERTY,
	BUDGIE_SHADOW_BLOCK_POSITION,
	BUDGIE_SHADOW_BLOCK_REQUIRED_SIZE,
	BUDGIE_SHADOW_BLOCK_REMOVAL
};
static void budgie_shadow_block_update_position (BudgieShadowBlock* self, BudgiePanelPosition* old);
BudgieShadowBlock* budgie_shadow_block_new (BudgiePanelPosition position);
BudgieShadowBlock* budgie_shadow_block_construct (GType object_type, BudgiePanelPosition position);
void budgie_shadow_block_set_position (BudgieShadowBlock* self, BudgiePanelPosition value);
static void budgie_shadow_block_real_get_preferred_height (GtkWidget* base, gint* min, gint* nat);
gint budgie_shadow_block_get_required_size (BudgieShadowBlock* self);
static void budgie_shadow_block_real_get_preferred_height_for_width (GtkWidget* base, gint width, gint* min, gint* nat);
static void budgie_shadow_block_real_get_preferred_width (GtkWidget* base, gint* min, gint* nat);
static void budgie_shadow_block_real_get_preferred_width_for_height (GtkWidget* base, gint height, gint* min, gint* nat);
BudgiePanelPosition budgie_shadow_block_get_position (BudgieShadowBlock* self);
void budgie_shadow_block_set_required_size (BudgieShadowBlock* self, gint value);
gint budgie_shadow_block_get_removal (BudgieShadowBlock* self);
void budgie_shadow_block_set_removal (BudgieShadowBlock* self, gint value);
static void budgie_shadow_block_finalize (GObject* obj);
static void _vala_budgie_shadow_block_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_budgie_shadow_block_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void budgie_shadow_block_update_position (BudgieShadowBlock* self, BudgiePanelPosition* old) {
	gboolean _tmp0_ = FALSE;
	BudgiePanelPosition _tmp1_ = 0;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->pos;
	if (_tmp1_ == BUDGIE_PANEL_POSITION_TOP) {
		_tmp0_ = TRUE;
	} else {
		BudgiePanelPosition _tmp2_ = 0;
		_tmp2_ = self->priv->pos;
		_tmp0_ = _tmp2_ == BUDGIE_PANEL_POSITION_BOTTOM;
	}
	if (_tmp0_) {
		self->priv->horizontal = TRUE;
	} else {
		self->priv->horizontal = FALSE;
	}
	gtk_widget_queue_resize ((GtkWidget*) self);
}


BudgieShadowBlock* budgie_shadow_block_construct (GType object_type, BudgiePanelPosition position) {
	BudgieShadowBlock * self = NULL;
	GtkStyleContext* _tmp0_ = NULL;
	GtkStyleContext* _tmp1_ = NULL;
	BudgiePanelPosition _tmp2_ = 0;
	self = (BudgieShadowBlock*) g_object_new (object_type, NULL);
	_tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp0_, "shadow-block");
	_tmp1_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_remove_class (_tmp1_, "background");
	_tmp2_ = position;
	budgie_shadow_block_set_position (self, _tmp2_);
	return self;
}


BudgieShadowBlock* budgie_shadow_block_new (BudgiePanelPosition position) {
	return budgie_shadow_block_construct (BUDGIE_TYPE_SHADOW_BLOCK, position);
}


static void budgie_shadow_block_real_get_preferred_height (GtkWidget* base, gint* min, gint* nat) {
	BudgieShadowBlock * self;
	gint _vala_min = 0;
	gint _vala_nat = 0;
	gboolean _tmp0_ = FALSE;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	self = (BudgieShadowBlock*) base;
	_tmp0_ = self->priv->horizontal;
	if (_tmp0_) {
		_vala_min = 5;
		_vala_nat = 5;
		if (min) {
			*min = _vala_min;
		}
		if (nat) {
			*nat = _vala_nat;
		}
		return;
	}
	_tmp1_ = budgie_shadow_block_get_required_size (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->rm;
	_vala_nat = _tmp2_ - _tmp3_;
	_tmp4_ = _vala_nat;
	_vala_min = _tmp4_;
	if (min) {
		*min = _vala_min;
	}
	if (nat) {
		*nat = _vala_nat;
	}
}


static void budgie_shadow_block_real_get_preferred_height_for_width (GtkWidget* base, gint width, gint* min, gint* nat) {
	BudgieShadowBlock * self;
	gint _vala_min = 0;
	gint _vala_nat = 0;
	gboolean _tmp0_ = FALSE;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	self = (BudgieShadowBlock*) base;
	_tmp0_ = self->priv->horizontal;
	if (_tmp0_) {
		_vala_min = 5;
		_vala_nat = 5;
		if (min) {
			*min = _vala_min;
		}
		if (nat) {
			*nat = _vala_nat;
		}
		return;
	}
	_tmp1_ = budgie_shadow_block_get_required_size (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->rm;
	_vala_nat = _tmp2_ - _tmp3_;
	_tmp4_ = _vala_nat;
	_vala_min = _tmp4_;
	if (min) {
		*min = _vala_min;
	}
	if (nat) {
		*nat = _vala_nat;
	}
}


static void budgie_shadow_block_real_get_preferred_width (GtkWidget* base, gint* min, gint* nat) {
	BudgieShadowBlock * self;
	gint _vala_min = 0;
	gint _vala_nat = 0;
	gboolean _tmp0_ = FALSE;
	gint _tmp5_ = 0;
	self = (BudgieShadowBlock*) base;
	_tmp0_ = self->priv->horizontal;
	if (_tmp0_) {
		gint _tmp1_ = 0;
		gint _tmp2_ = 0;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		_tmp1_ = budgie_shadow_block_get_required_size (self);
		_tmp2_ = _tmp1_;
		_tmp3_ = self->priv->rm;
		_vala_nat = _tmp2_ - _tmp3_;
		_tmp4_ = _vala_nat;
		_vala_min = _tmp4_;
		if (min) {
			*min = _vala_min;
		}
		if (nat) {
			*nat = _vala_nat;
		}
		return;
	}
	_vala_nat = 5;
	_tmp5_ = _vala_nat;
	_vala_min = _tmp5_;
	if (min) {
		*min = _vala_min;
	}
	if (nat) {
		*nat = _vala_nat;
	}
}


static void budgie_shadow_block_real_get_preferred_width_for_height (GtkWidget* base, gint height, gint* min, gint* nat) {
	BudgieShadowBlock * self;
	gint _vala_min = 0;
	gint _vala_nat = 0;
	gboolean _tmp0_ = FALSE;
	gint _tmp5_ = 0;
	self = (BudgieShadowBlock*) base;
	_tmp0_ = self->priv->horizontal;
	if (_tmp0_) {
		gint _tmp1_ = 0;
		gint _tmp2_ = 0;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		_tmp1_ = budgie_shadow_block_get_required_size (self);
		_tmp2_ = _tmp1_;
		_tmp3_ = self->priv->rm;
		_vala_nat = _tmp2_ - _tmp3_;
		_tmp4_ = _vala_nat;
		_vala_min = _tmp4_;
		if (min) {
			*min = _vala_min;
		}
		if (nat) {
			*nat = _vala_nat;
		}
		return;
	}
	_vala_nat = 5;
	_tmp5_ = _vala_nat;
	_vala_min = _tmp5_;
	if (min) {
		*min = _vala_min;
	}
	if (nat) {
		*nat = _vala_nat;
	}
}


BudgiePanelPosition budgie_shadow_block_get_position (BudgieShadowBlock* self) {
	BudgiePanelPosition result;
	BudgiePanelPosition _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->pos;
	result = _tmp0_;
	return result;
}


void budgie_shadow_block_set_position (BudgieShadowBlock* self, BudgiePanelPosition value) {
	BudgiePanelPosition old = 0;
	BudgiePanelPosition _tmp0_ = 0;
	BudgiePanelPosition _tmp1_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->pos;
	old = _tmp0_;
	_tmp1_ = value;
	self->priv->pos = _tmp1_;
	budgie_shadow_block_update_position (self, &old);
	g_object_notify ((GObject *) self, "position");
}


gint budgie_shadow_block_get_required_size (BudgieShadowBlock* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->size;
	result = _tmp0_;
	return result;
}


void budgie_shadow_block_set_required_size (BudgieShadowBlock* self, gint value) {
	gint _tmp0_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->size = _tmp0_;
	gtk_widget_queue_resize ((GtkWidget*) self);
	g_object_notify ((GObject *) self, "required-size");
}


gint budgie_shadow_block_get_removal (BudgieShadowBlock* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->rm;
	result = _tmp0_;
	return result;
}


void budgie_shadow_block_set_removal (BudgieShadowBlock* self, gint value) {
	gint _tmp0_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->rm = _tmp0_;
	gtk_widget_queue_resize ((GtkWidget*) self);
	g_object_notify ((GObject *) self, "removal");
}


static void budgie_shadow_block_class_init (BudgieShadowBlockClass * klass) {
	budgie_shadow_block_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (BudgieShadowBlockPrivate));
	((GtkWidgetClass *) klass)->get_preferred_height = budgie_shadow_block_real_get_preferred_height;
	((GtkWidgetClass *) klass)->get_preferred_height_for_width = budgie_shadow_block_real_get_preferred_height_for_width;
	((GtkWidgetClass *) klass)->get_preferred_width = budgie_shadow_block_real_get_preferred_width;
	((GtkWidgetClass *) klass)->get_preferred_width_for_height = budgie_shadow_block_real_get_preferred_width_for_height;
	G_OBJECT_CLASS (klass)->get_property = _vala_budgie_shadow_block_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_budgie_shadow_block_set_property;
	G_OBJECT_CLASS (klass)->finalize = budgie_shadow_block_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BUDGIE_SHADOW_BLOCK_POSITION, g_param_spec_flags ("position", "position", "position", BUDGIE_TYPE_PANEL_POSITION, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BUDGIE_SHADOW_BLOCK_REQUIRED_SIZE, g_param_spec_int ("required-size", "required-size", "required-size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BUDGIE_SHADOW_BLOCK_REMOVAL, g_param_spec_int ("removal", "removal", "removal", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void budgie_shadow_block_instance_init (BudgieShadowBlock * self) {
	self->priv = BUDGIE_SHADOW_BLOCK_GET_PRIVATE (self);
	self->priv->horizontal = FALSE;
	self->priv->rm = 0;
}


static void budgie_shadow_block_finalize (GObject* obj) {
	BudgieShadowBlock * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BUDGIE_TYPE_SHADOW_BLOCK, BudgieShadowBlock);
	G_OBJECT_CLASS (budgie_shadow_block_parent_class)->finalize (obj);
}


/**
 * Alternative to a separator, gives a shadow effect
 */
GType budgie_shadow_block_get_type (void) {
	static volatile gsize budgie_shadow_block_type_id__volatile = 0;
	if (g_once_init_enter (&budgie_shadow_block_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BudgieShadowBlockClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) budgie_shadow_block_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BudgieShadowBlock), 0, (GInstanceInitFunc) budgie_shadow_block_instance_init, NULL };
		GType budgie_shadow_block_type_id;
		budgie_shadow_block_type_id = g_type_register_static (gtk_event_box_get_type (), "BudgieShadowBlock", &g_define_type_info, 0);
		g_once_init_leave (&budgie_shadow_block_type_id__volatile, budgie_shadow_block_type_id);
	}
	return budgie_shadow_block_type_id__volatile;
}


static void _vala_budgie_shadow_block_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	BudgieShadowBlock * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BUDGIE_TYPE_SHADOW_BLOCK, BudgieShadowBlock);
	switch (property_id) {
		case BUDGIE_SHADOW_BLOCK_POSITION:
		g_value_set_flags (value, budgie_shadow_block_get_position (self));
		break;
		case BUDGIE_SHADOW_BLOCK_REQUIRED_SIZE:
		g_value_set_int (value, budgie_shadow_block_get_required_size (self));
		break;
		case BUDGIE_SHADOW_BLOCK_REMOVAL:
		g_value_set_int (value, budgie_shadow_block_get_removal (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_budgie_shadow_block_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	BudgieShadowBlock * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BUDGIE_TYPE_SHADOW_BLOCK, BudgieShadowBlock);
	switch (property_id) {
		case BUDGIE_SHADOW_BLOCK_POSITION:
		budgie_shadow_block_set_position (self, g_value_get_flags (value));
		break;
		case BUDGIE_SHADOW_BLOCK_REQUIRED_SIZE:
		budgie_shadow_block_set_required_size (self, g_value_get_int (value));
		break;
		case BUDGIE_SHADOW_BLOCK_REMOVAL:
		budgie_shadow_block_set_removal (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



