/* tile-view.c generated by valac 0.11.6, the Vala compiler
 * generated from tile-view.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <string.h>
#include <float.h>
#include <math.h>


#define DOCK_MANAGER_TYPE_TILE_VIEW (dock_manager_tile_view_get_type ())
#define DOCK_MANAGER_TILE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DOCK_MANAGER_TYPE_TILE_VIEW, DockManagerTileView))
#define DOCK_MANAGER_TILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DOCK_MANAGER_TYPE_TILE_VIEW, DockManagerTileViewClass))
#define DOCK_MANAGER_IS_TILE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DOCK_MANAGER_TYPE_TILE_VIEW))
#define DOCK_MANAGER_IS_TILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DOCK_MANAGER_TYPE_TILE_VIEW))
#define DOCK_MANAGER_TILE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DOCK_MANAGER_TYPE_TILE_VIEW, DockManagerTileViewClass))

typedef struct _DockManagerTileView DockManagerTileView;
typedef struct _DockManagerTileViewClass DockManagerTileViewClass;
typedef struct _DockManagerTileViewPrivate DockManagerTileViewPrivate;

#define DOCK_MANAGER_TYPE_ABSTRACT_TILE_OBJECT (dock_manager_abstract_tile_object_get_type ())
#define DOCK_MANAGER_ABSTRACT_TILE_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DOCK_MANAGER_TYPE_ABSTRACT_TILE_OBJECT, DockManagerAbstractTileObject))
#define DOCK_MANAGER_ABSTRACT_TILE_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DOCK_MANAGER_TYPE_ABSTRACT_TILE_OBJECT, DockManagerAbstractTileObjectClass))
#define DOCK_MANAGER_IS_ABSTRACT_TILE_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DOCK_MANAGER_TYPE_ABSTRACT_TILE_OBJECT))
#define DOCK_MANAGER_IS_ABSTRACT_TILE_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DOCK_MANAGER_TYPE_ABSTRACT_TILE_OBJECT))
#define DOCK_MANAGER_ABSTRACT_TILE_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DOCK_MANAGER_TYPE_ABSTRACT_TILE_OBJECT, DockManagerAbstractTileObjectClass))

typedef struct _DockManagerAbstractTileObject DockManagerAbstractTileObject;
typedef struct _DockManagerAbstractTileObjectClass DockManagerAbstractTileObjectClass;

#define DOCK_MANAGER_TYPE_TILE (dock_manager_tile_get_type ())
#define DOCK_MANAGER_TILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DOCK_MANAGER_TYPE_TILE, DockManagerTile))
#define DOCK_MANAGER_TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DOCK_MANAGER_TYPE_TILE, DockManagerTileClass))
#define DOCK_MANAGER_IS_TILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DOCK_MANAGER_TYPE_TILE))
#define DOCK_MANAGER_IS_TILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DOCK_MANAGER_TYPE_TILE))
#define DOCK_MANAGER_TILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DOCK_MANAGER_TYPE_TILE, DockManagerTileClass))

typedef struct _DockManagerTile DockManagerTile;
typedef struct _DockManagerTileClass DockManagerTileClass;
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
#define _gdk_region_destroy0(var) ((var == NULL) ? NULL : (var = (gdk_region_destroy (var), NULL)))

struct _DockManagerTileView {
	GtkEventBox parent_instance;
	DockManagerTileViewPrivate * priv;
	gint selected_index;
};

struct _DockManagerTileViewClass {
	GtkEventBoxClass parent_class;
	void (*append_tile) (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj);
	void (*remove_tile) (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj);
	void (*clear_selection) (DockManagerTileView* self);
	DockManagerAbstractTileObject* (*get_current_tile) (DockManagerTileView* self);
	void (*on_tile_active_changed) (DockManagerTileView* self, DockManagerTile* tile);
	void (*on_tile_size_allocated) (DockManagerTileView* self, GtkWidget* w, GdkRectangle* alloc);
};

struct _DockManagerTileViewPrivate {
	GList* tiles;
	GtkVBox* box;
	gint _icon_size;
	gboolean changing_style;
};


static gpointer dock_manager_tile_view_parent_class = NULL;

GType dock_manager_tile_view_get_type (void) G_GNUC_CONST;
GType dock_manager_abstract_tile_object_get_type (void) G_GNUC_CONST;
GType dock_manager_tile_get_type (void) G_GNUC_CONST;
#define DOCK_MANAGER_TILE_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DOCK_MANAGER_TYPE_TILE_VIEW, DockManagerTileViewPrivate))
enum  {
	DOCK_MANAGER_TILE_VIEW_DUMMY_PROPERTY,
	DOCK_MANAGER_TILE_VIEW_ICON_SIZE
};
static void _g_object_unref0_ (gpointer var);
static void _g_list_free__g_object_unref0_ (GList* self);
DockManagerTileView* dock_manager_tile_view_new (void);
DockManagerTileView* dock_manager_tile_view_construct (GType object_type);
gboolean dock_manager_tile_view_on_button_press (DockManagerTileView* self, GdkEventButton* event);
static gboolean _dock_manager_tile_view_on_button_press_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
gboolean dock_manager_tile_view_on_key_press (DockManagerTileView* self, GdkEventKey* event);
static gboolean _dock_manager_tile_view_on_key_press_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self);
void dock_manager_tile_view_append_tile (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj);
static void dock_manager_tile_view_real_append_tile (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj);
gint dock_manager_tile_view_get_icon_size (DockManagerTileView* self);
DockManagerTile* dock_manager_tile_new (DockManagerAbstractTileObject* obj, gint icon_size);
DockManagerTile* dock_manager_tile_construct (GType object_type, DockManagerAbstractTileObject* obj, gint icon_size);
void dock_manager_tile_set_owner (DockManagerTile* self, DockManagerTileView* value);
void dock_manager_tile_view_on_tile_active_changed (DockManagerTileView* self, DockManagerTile* tile);
static void _dock_manager_tile_view_on_tile_active_changed_dock_manager_tile_active_changed (DockManagerTile* _sender, gpointer self);
void dock_manager_tile_view_on_tile_size_allocated (DockManagerTileView* self, GtkWidget* w, GdkRectangle* alloc);
static void _dock_manager_tile_view_on_tile_size_allocated_gtk_widget_size_allocate (GtkWidget* _sender, GdkRectangle* allocation, gpointer self);
void dock_manager_tile_view_remove_tile (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj);
static void dock_manager_tile_view_real_remove_tile (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj);
DockManagerAbstractTileObject* dock_manager_tile_get_owned_object (DockManagerTile* self);
void dock_manager_tile_view_clear_selection (DockManagerTileView* self);
GList* dock_manager_tile_view_get_tiles (DockManagerTileView* self);
void dock_manager_tile_view_clear (DockManagerTileView* self);
static void dock_manager_tile_view_real_clear_selection (DockManagerTileView* self);
void dock_manager_tile_set_selected (DockManagerTile* self, gboolean selected);
DockManagerAbstractTileObject* dock_manager_tile_view_get_current_tile (DockManagerTileView* self);
static DockManagerAbstractTileObject* dock_manager_tile_view_real_get_current_tile (DockManagerTileView* self);
static void dock_manager_tile_view_real_style_set (GtkWidget* base, GtkStyle* prev_style);
static void dock_manager_tile_view_real_on_tile_active_changed (DockManagerTileView* self, DockManagerTile* tile);
void dock_manager_tile_update_state (DockManagerTile* self);
static void dock_manager_tile_view_real_on_tile_size_allocated (DockManagerTileView* self, GtkWidget* w, GdkRectangle* alloc);
void dock_manager_tile_view_select (DockManagerTileView* self, gint index);
void dock_manager_tile_view_set_icon_size (DockManagerTileView* self, gint value);
static void dock_manager_tile_view_finalize (GObject* obj);
static void _vala_dock_manager_tile_view_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_dock_manager_tile_view_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void _g_object_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static void _g_list_free__g_object_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
	g_list_free (self);
}


static gboolean _dock_manager_tile_view_on_button_press_gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = dock_manager_tile_view_on_button_press (self, event);
	return result;
}


static gboolean _dock_manager_tile_view_on_key_press_gtk_widget_key_press_event (GtkWidget* _sender, GdkEventKey* event, gpointer self) {
	gboolean result;
	result = dock_manager_tile_view_on_key_press (self, event);
	return result;
}


DockManagerTileView* dock_manager_tile_view_construct (GType object_type) {
	DockManagerTileView * self = NULL;
	self = (DockManagerTileView*) g_object_new (object_type, "can-focus", TRUE, "visible-window", FALSE, NULL);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) _dock_manager_tile_view_on_button_press_gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "key-press-event", (GCallback) _dock_manager_tile_view_on_key_press_gtk_widget_key_press_event, self, 0);
	gtk_widget_show ((GtkWidget*) self->priv->box);
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) self->priv->box);
	return self;
}


DockManagerTileView* dock_manager_tile_view_new (void) {
	return dock_manager_tile_view_construct (DOCK_MANAGER_TYPE_TILE_VIEW);
}


static void _dock_manager_tile_view_on_tile_active_changed_dock_manager_tile_active_changed (DockManagerTile* _sender, gpointer self) {
	dock_manager_tile_view_on_tile_active_changed (self, _sender);
}


static void _dock_manager_tile_view_on_tile_size_allocated_gtk_widget_size_allocate (GtkWidget* _sender, GdkRectangle* allocation, gpointer self) {
	dock_manager_tile_view_on_tile_size_allocated (self, _sender, allocation);
}


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


static void dock_manager_tile_view_real_append_tile (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj) {
	DockManagerTile* _tmp0_ = NULL;
	DockManagerTile* tile;
	DockManagerTile* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tile_obj != NULL);
	_tmp0_ = dock_manager_tile_new (tile_obj, self->priv->_icon_size);
	tile = g_object_ref_sink (_tmp0_);
	dock_manager_tile_set_owner (tile, self);
	g_signal_connect_object (tile, "active-changed", (GCallback) _dock_manager_tile_view_on_tile_active_changed_dock_manager_tile_active_changed, self, 0);
	g_signal_connect_object ((GtkWidget*) tile, "size-allocate", (GCallback) _dock_manager_tile_view_on_tile_size_allocated_gtk_widget_size_allocate, self, 0);
	gtk_widget_show ((GtkWidget*) tile);
	_tmp1_ = _g_object_ref0 (tile);
	self->priv->tiles = g_list_append (self->priv->tiles, _tmp1_);
	gtk_box_pack_start ((GtkBox*) self->priv->box, (GtkWidget*) tile, FALSE, FALSE, (guint) 0);
	_g_object_unref0 (tile);
}


void dock_manager_tile_view_append_tile (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj) {
	DOCK_MANAGER_TILE_VIEW_GET_CLASS (self)->append_tile (self, tile_obj);
}


static void dock_manager_tile_view_real_remove_tile (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj) {
	DockManagerTile* tile;
	gint _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tile_obj != NULL);
	tile = NULL;
	{
		GList* t_collection;
		GList* t_it;
		t_collection = self->priv->tiles;
		for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
			DockManagerTile* t;
			t = (DockManagerTile*) t_it->data;
			{
				DockManagerAbstractTileObject* _tmp0_ = NULL;
				_tmp0_ = dock_manager_tile_get_owned_object (t);
				if (_tmp0_ == tile_obj) {
					tile = t;
					break;
				}
			}
		}
	}
	if (tile == NULL) {
		g_warning ("tile-view.vala:51: Container does not own this AbstractTileObject!");
		return;
	}
	_tmp1_ = g_list_index (self->priv->tiles, tile);
	if (self->selected_index == _tmp1_) {
		dock_manager_tile_view_clear_selection (self);
	}
	gtk_widget_hide ((GtkWidget*) tile);
	g_signal_parse_name ("active-changed", DOCK_MANAGER_TYPE_TILE, &_tmp2_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (tile, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _dock_manager_tile_view_on_tile_active_changed_dock_manager_tile_active_changed, self);
	g_signal_parse_name ("size-allocate", GTK_TYPE_WIDGET, &_tmp3_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((GtkWidget*) tile, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _dock_manager_tile_view_on_tile_size_allocated_gtk_widget_size_allocate, self);
	dock_manager_tile_set_owner (tile, NULL);
	gtk_container_remove ((GtkContainer*) self->priv->box, (GtkWidget*) tile);
	self->priv->tiles = g_list_remove (self->priv->tiles, tile);
}


void dock_manager_tile_view_remove_tile (DockManagerTileView* self, DockManagerAbstractTileObject* tile_obj) {
	DOCK_MANAGER_TILE_VIEW_GET_CLASS (self)->remove_tile (self, tile_obj);
}


GList* dock_manager_tile_view_get_tiles (DockManagerTileView* self) {
	GList* result = NULL;
	GList* _result_;
	g_return_val_if_fail (self != NULL, NULL);
	_result_ = NULL;
	{
		GList* t_collection;
		GList* t_it;
		t_collection = self->priv->tiles;
		for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
			DockManagerTile* t;
			t = (DockManagerTile*) t_it->data;
			{
				DockManagerAbstractTileObject* _tmp0_ = NULL;
				_tmp0_ = dock_manager_tile_get_owned_object (t);
				_result_ = g_list_prepend (_result_, _tmp0_);
			}
		}
	}
	_result_ = g_list_reverse (_result_);
	result = _result_;
	return result;
}


void dock_manager_tile_view_clear (DockManagerTileView* self) {
	GList* _tmp0_ = NULL;
	GList* tiles_copy;
	g_return_if_fail (self != NULL);
	_tmp0_ = dock_manager_tile_view_get_tiles (self);
	tiles_copy = _tmp0_;
	{
		GList* to_collection;
		GList* to_it;
		to_collection = tiles_copy;
		for (to_it = to_collection; to_it != NULL; to_it = to_it->next) {
			DockManagerAbstractTileObject* to;
			to = (DockManagerAbstractTileObject*) to_it->data;
			{
				dock_manager_tile_view_remove_tile (self, to);
			}
		}
	}
	_g_list_free0 (tiles_copy);
}


static void dock_manager_tile_view_real_clear_selection (DockManagerTileView* self) {
	guint _tmp0_;
	gint _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_list_length (self->priv->tiles);
	if ((_tmp1_ = self->selected_index, 0 <= _tmp1_) && (_tmp1_ < _tmp0_)) {
		gconstpointer _tmp2_ = NULL;
		_tmp2_ = g_list_nth_data (self->priv->tiles, (guint) self->selected_index);
		dock_manager_tile_set_selected ((DockManagerTile*) _tmp2_, FALSE);
	}
	self->selected_index = -1;
}


void dock_manager_tile_view_clear_selection (DockManagerTileView* self) {
	DOCK_MANAGER_TILE_VIEW_GET_CLASS (self)->clear_selection (self);
}


static DockManagerAbstractTileObject* dock_manager_tile_view_real_get_current_tile (DockManagerTileView* self) {
	DockManagerAbstractTileObject* result = NULL;
	guint _tmp0_;
	gint _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_list_length (self->priv->tiles);
	if ((_tmp1_ = self->selected_index, 0 <= _tmp1_) && (_tmp1_ < _tmp0_)) {
		gconstpointer _tmp2_ = NULL;
		DockManagerAbstractTileObject* _tmp3_ = NULL;
		DockManagerAbstractTileObject* _tmp4_;
		_tmp2_ = g_list_nth_data (self->priv->tiles, (guint) self->selected_index);
		_tmp3_ = dock_manager_tile_get_owned_object ((DockManagerTile*) _tmp2_);
		_tmp4_ = _g_object_ref0 (_tmp3_);
		result = _tmp4_;
		return result;
	}
	result = NULL;
	return result;
}


DockManagerAbstractTileObject* dock_manager_tile_view_get_current_tile (DockManagerTileView* self) {
	return DOCK_MANAGER_TILE_VIEW_GET_CLASS (self)->get_current_tile (self);
}


static void dock_manager_tile_view_real_style_set (GtkWidget* base, GtkStyle* prev_style) {
	DockManagerTileView * self;
	GtkContainer* _tmp0_ = NULL;
	GtkStyle* _tmp1_ = NULL;
	GdkColor _tmp2_;
	self = (DockManagerTileView*) base;
	if (self->priv->changing_style) {
		return;
	}
	self->priv->changing_style = TRUE;
	GTK_WIDGET_CLASS (dock_manager_tile_view_parent_class)->style_set ((GtkWidget*) GTK_EVENT_BOX (self), prev_style);
	_tmp0_ = gtk_widget_get_parent ((GtkWidget*) self);
	_tmp1_ = gtk_widget_get_style ((GtkWidget*) self);
	gtk_widget_modify_bg ((GtkWidget*) _tmp0_, GTK_STATE_NORMAL, (_tmp2_ = _tmp1_->base[GTK_STATE_NORMAL], &_tmp2_));
	self->priv->changing_style = FALSE;
}


static void dock_manager_tile_view_real_on_tile_active_changed (DockManagerTileView* self, DockManagerTile* tile) {
	DockManagerAbstractTileObject* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tile != NULL);
	_tmp0_ = dock_manager_tile_get_owned_object (tile);
	g_signal_emit_by_name (_tmp0_, "active-changed");
	{
		GList* t_collection;
		GList* t_it;
		t_collection = self->priv->tiles;
		for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
			DockManagerTile* t;
			t = (DockManagerTile*) t_it->data;
			{
				dock_manager_tile_update_state (t);
			}
		}
	}
}


void dock_manager_tile_view_on_tile_active_changed (DockManagerTileView* self, DockManagerTile* tile) {
	DOCK_MANAGER_TILE_VIEW_GET_CLASS (self)->on_tile_active_changed (self, tile);
}


static void dock_manager_tile_view_real_on_tile_size_allocated (DockManagerTileView* self, GtkWidget* w, GdkRectangle* alloc) {
	GtkWidget* _tmp0_;
	DockManagerTile* _tmp1_;
	DockManagerTile* tile;
	GtkScrolledWindow* scroll;
	GtkScrolledWindow* _tmp2_ = NULL;
	GtkWidget* _tmp3_ = NULL;
	GtkScrolledWindow* _tmp7_;
	GtkScrolledWindow* _tmp8_;
	gint _tmp9_;
	GdkRectangle va = {0};
	GtkAdjustment* _tmp10_ = NULL;
	gdouble _tmp11_;
	GtkWidget* _tmp12_ = NULL;
	GdkRegion* _tmp13_ = NULL;
	GdkRegion* va_region;
	GdkOverlapType _tmp14_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (w != NULL);
	_tmp1_ = _g_object_ref0 ((_tmp0_ = w, DOCK_MANAGER_IS_TILE (_tmp0_) ? ((DockManagerTile*) _tmp0_) : NULL));
	tile = _tmp1_;
	scroll = NULL;
	_tmp3_ = gtk_widget_get_parent ((GtkWidget*) self);
	if (_tmp3_ == NULL) {
		_tmp2_ = NULL;
	} else {
		GtkWidget* _tmp4_ = NULL;
		GtkWidget* _tmp5_ = NULL;
		GtkWidget* _tmp6_;
		_tmp4_ = gtk_widget_get_parent ((GtkWidget*) self);
		_tmp5_ = gtk_widget_get_parent (_tmp4_);
		_tmp2_ = (_tmp6_ = _tmp5_, GTK_IS_SCROLLED_WINDOW (_tmp6_) ? ((GtkScrolledWindow*) _tmp6_) : NULL);
	}
	_tmp7_ = _g_object_ref0 (_tmp2_);
	_tmp8_ = _tmp7_;
	_g_object_unref0 (scroll);
	scroll = _tmp8_;
	if (scroll == NULL) {
		_g_object_unref0 (scroll);
		_g_object_unref0 (tile);
		return;
	}
	_tmp9_ = g_list_index (self->priv->tiles, tile);
	if (_tmp9_ != self->selected_index) {
		_g_object_unref0 (scroll);
		_g_object_unref0 (tile);
		return;
	}
	memset (&va, 0, sizeof (GdkRectangle));
	va.x = 0;
	_tmp10_ = gtk_scrolled_window_get_vadjustment (scroll);
	_tmp11_ = gtk_adjustment_get_value (_tmp10_);
	va.y = (gint) _tmp11_;
	va.width = (*alloc).width;
	_tmp12_ = gtk_widget_get_parent ((GtkWidget*) self);
	va.height = _tmp12_->allocation.height;
	_tmp13_ = gdk_region_rectangle (&va);
	va_region = _tmp13_;
	_tmp14_ = gdk_region_rect_in (va_region, alloc);
	if (_tmp14_ != GDK_OVERLAP_RECTANGLE_IN) {
		gdouble delta;
		GtkAdjustment* _tmp16_ = NULL;
		delta = 0.0;
		if (((*alloc).y + (*alloc).height) > (va.y + va.height)) {
			GtkStyle* _tmp15_ = NULL;
			delta = (gdouble) (((*alloc).y + (*alloc).height) - (va.y + va.height));
			_tmp15_ = gtk_widget_get_style ((GtkWidget*) self);
			delta = delta + ((gdouble) (_tmp15_->ythickness * 2));
		} else {
			if ((*alloc).y < va.y) {
				delta = (gdouble) ((*alloc).y - va.y);
			}
		}
		_tmp16_ = gtk_scrolled_window_get_vadjustment (scroll);
		gtk_adjustment_set_value (_tmp16_, va.y + delta);
		gtk_widget_queue_draw ((GtkWidget*) self);
	}
	_gdk_region_destroy0 (va_region);
	_g_object_unref0 (scroll);
	_g_object_unref0 (tile);
}


void dock_manager_tile_view_on_tile_size_allocated (DockManagerTileView* self, GtkWidget* w, GdkRectangle* alloc) {
	DOCK_MANAGER_TILE_VIEW_GET_CLASS (self)->on_tile_size_allocated (self, w, alloc);
}


gboolean dock_manager_tile_view_on_button_press (DockManagerTileView* self, GdkEventButton* event) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_object_set ((GtkWidget*) self, "has-focus", TRUE, NULL);
	dock_manager_tile_view_clear_selection (self);
	{
		gint i;
		i = 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				guint _tmp1_;
				gconstpointer _tmp2_ = NULL;
				DockManagerTile* t;
				GdkRectangle* rect_ptr;
				GdkRegion* _tmp3_ = NULL;
				GdkRegion* region;
				gboolean _tmp4_;
				if (!_tmp0_) {
					i++;
				}
				_tmp0_ = FALSE;
				_tmp1_ = g_list_length (self->priv->tiles);
				if (!(i < _tmp1_)) {
					break;
				}
				_tmp2_ = g_list_nth_data (self->priv->tiles, (guint) i);
				t = (DockManagerTile*) _tmp2_;
				rect_ptr = (GdkRectangle*) (&((GtkWidget*) t)->allocation);
				_tmp3_ = gdk_region_rectangle (rect_ptr);
				region = _tmp3_;
				_tmp4_ = gdk_region_point_in (region, (gint) (*event).x, (gint) (*event).y);
				if (_tmp4_) {
					dock_manager_tile_view_select (self, i);
					_gdk_region_destroy0 (region);
					break;
				}
				_gdk_region_destroy0 (region);
			}
		}
	}
	gtk_widget_queue_draw ((GtkWidget*) self);
	result = FALSE;
	return result;
}


gboolean dock_manager_tile_view_on_key_press (DockManagerTileView* self, GdkEventKey* event) {
	gboolean result = FALSE;
	gint index;
	guint _tmp0_;
	gint _tmp1_;
	g_return_val_if_fail (self != NULL, FALSE);
	index = self->selected_index;
	switch ((*event).keyval) {
		case 0xff52:
		case 0x8fc:
		{
			index--;
			break;
		}
		case 0xff54:
		case 0x8fe:
		{
			index++;
			break;
		}
		default:
		break;
	}
	_tmp0_ = g_list_length (self->priv->tiles);
	_tmp1_ = CLAMP (index, 0, ((gint) _tmp0_) - 1);
	index = _tmp1_;
	if (index != self->selected_index) {
		dock_manager_tile_view_clear_selection (self);
		dock_manager_tile_view_select (self, index);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


void dock_manager_tile_view_select (DockManagerTileView* self, gint index) {
	guint _tmp0_;
	gint _tmp1_;
	gboolean _tmp3_ = FALSE;
	GtkWidget* _tmp4_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_list_length (self->priv->tiles);
	if ((_tmp1_ = index, 0 <= _tmp1_) && (_tmp1_ < _tmp0_)) {
		gconstpointer _tmp2_ = NULL;
		self->selected_index = index;
		_tmp2_ = g_list_nth_data (self->priv->tiles, (guint) index);
		dock_manager_tile_set_selected ((DockManagerTile*) _tmp2_, TRUE);
	} else {
		dock_manager_tile_view_clear_selection (self);
	}
	_tmp4_ = gtk_widget_get_parent ((GtkWidget*) self);
	if (_tmp4_ != NULL) {
		GtkWidget* _tmp5_ = NULL;
		gboolean _tmp6_;
		_tmp5_ = gtk_widget_get_parent ((GtkWidget*) self);
		_tmp6_ = GTK_WIDGET_REALIZED (_tmp5_);
		_tmp3_ = _tmp6_;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		GtkWidget* _tmp7_ = NULL;
		_tmp7_ = gtk_widget_get_parent ((GtkWidget*) self);
		gtk_widget_queue_draw (_tmp7_);
	}
	gtk_widget_queue_resize ((GtkWidget*) self);
}


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


void dock_manager_tile_view_set_icon_size (DockManagerTileView* self, gint value) {
	g_return_if_fail (self != NULL);
	self->priv->_icon_size = value;
	g_object_notify ((GObject *) self, "icon-size");
}


static void dock_manager_tile_view_class_init (DockManagerTileViewClass * klass) {
	dock_manager_tile_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DockManagerTileViewPrivate));
	DOCK_MANAGER_TILE_VIEW_CLASS (klass)->append_tile = dock_manager_tile_view_real_append_tile;
	DOCK_MANAGER_TILE_VIEW_CLASS (klass)->remove_tile = dock_manager_tile_view_real_remove_tile;
	DOCK_MANAGER_TILE_VIEW_CLASS (klass)->clear_selection = dock_manager_tile_view_real_clear_selection;
	DOCK_MANAGER_TILE_VIEW_CLASS (klass)->get_current_tile = dock_manager_tile_view_real_get_current_tile;
	GTK_WIDGET_CLASS (klass)->style_set = dock_manager_tile_view_real_style_set;
	DOCK_MANAGER_TILE_VIEW_CLASS (klass)->on_tile_active_changed = dock_manager_tile_view_real_on_tile_active_changed;
	DOCK_MANAGER_TILE_VIEW_CLASS (klass)->on_tile_size_allocated = dock_manager_tile_view_real_on_tile_size_allocated;
	G_OBJECT_CLASS (klass)->get_property = _vala_dock_manager_tile_view_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dock_manager_tile_view_set_property;
	G_OBJECT_CLASS (klass)->finalize = dock_manager_tile_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DOCK_MANAGER_TILE_VIEW_ICON_SIZE, g_param_spec_int ("icon-size", "icon-size", "icon-size", G_MININT, G_MAXINT, 48, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}


static void dock_manager_tile_view_instance_init (DockManagerTileView * self) {
	GtkVBox* _tmp0_ = NULL;
	self->priv = DOCK_MANAGER_TILE_VIEW_GET_PRIVATE (self);
	self->priv->tiles = NULL;
	_tmp0_ = (GtkVBox*) gtk_vbox_new (FALSE, 0);
	self->priv->box = g_object_ref_sink (_tmp0_);
	self->priv->_icon_size = 48;
	self->selected_index = -1;
	self->priv->changing_style = FALSE;
}


static void dock_manager_tile_view_finalize (GObject* obj) {
	DockManagerTileView * self;
	self = DOCK_MANAGER_TILE_VIEW (obj);
	__g_list_free__g_object_unref0_0 (self->priv->tiles);
	_g_object_unref0 (self->priv->box);
	G_OBJECT_CLASS (dock_manager_tile_view_parent_class)->finalize (obj);
}


GType dock_manager_tile_view_get_type (void) {
	static volatile gsize dock_manager_tile_view_type_id__volatile = 0;
	if (g_once_init_enter (&dock_manager_tile_view_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DockManagerTileViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dock_manager_tile_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DockManagerTileView), 0, (GInstanceInitFunc) dock_manager_tile_view_instance_init, NULL };
		GType dock_manager_tile_view_type_id;
		dock_manager_tile_view_type_id = g_type_register_static (GTK_TYPE_EVENT_BOX, "DockManagerTileView", &g_define_type_info, 0);
		g_once_init_leave (&dock_manager_tile_view_type_id__volatile, dock_manager_tile_view_type_id);
	}
	return dock_manager_tile_view_type_id__volatile;
}


static void _vala_dock_manager_tile_view_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	DockManagerTileView * self;
	self = DOCK_MANAGER_TILE_VIEW (object);
	switch (property_id) {
		case DOCK_MANAGER_TILE_VIEW_ICON_SIZE:
		g_value_set_int (value, dock_manager_tile_view_get_icon_size (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_dock_manager_tile_view_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	DockManagerTileView * self;
	self = DOCK_MANAGER_TILE_VIEW (object);
	switch (property_id) {
		case DOCK_MANAGER_TILE_VIEW_ICON_SIZE:
		dock_manager_tile_view_set_icon_size (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



