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

/**/
/*  Copyright (C) 2017 Rico Tzschichholz*/
/**/
/*  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 <plank.h>
#include <glib-object.h>
#include <gmenu-tree.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <gee.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gio/gdesktopappinfo.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 DOCKY_TYPE_APPLICATIONS_DOCK_ITEM (docky_applications_dock_item_get_type ())
#define DOCKY_APPLICATIONS_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DOCKY_TYPE_APPLICATIONS_DOCK_ITEM, DockyApplicationsDockItem))
#define DOCKY_APPLICATIONS_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DOCKY_TYPE_APPLICATIONS_DOCK_ITEM, DockyApplicationsDockItemClass))
#define DOCKY_IS_APPLICATIONS_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DOCKY_TYPE_APPLICATIONS_DOCK_ITEM))
#define DOCKY_IS_APPLICATIONS_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DOCKY_TYPE_APPLICATIONS_DOCK_ITEM))
#define DOCKY_APPLICATIONS_DOCK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DOCKY_TYPE_APPLICATIONS_DOCK_ITEM, DockyApplicationsDockItemClass))

typedef struct _DockyApplicationsDockItem DockyApplicationsDockItem;
typedef struct _DockyApplicationsDockItemClass DockyApplicationsDockItemClass;
typedef struct _DockyApplicationsDockItemPrivate DockyApplicationsDockItemPrivate;
enum  {
	DOCKY_APPLICATIONS_DOCK_ITEM_0_PROPERTY,
	DOCKY_APPLICATIONS_DOCK_ITEM_NUM_PROPERTIES
};
static GParamSpec* docky_applications_dock_item_properties[DOCKY_APPLICATIONS_DOCK_ITEM_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __vala_GMenuTreeDirectory_free0(var) ((var == NULL) ? NULL : (var = (_vala_GMenuTreeDirectory_free (var), NULL)))
#define __vala_GMenuTreeIter_free0(var) ((var == NULL) ? NULL : (var = (_vala_GMenuTreeIter_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block1Data Block1Data;
#define __vala_GMenuTreeEntry_free0(var) ((var == NULL) ? NULL : (var = (_vala_GMenuTreeEntry_free (var), NULL)))

struct _DockyApplicationsDockItem {
	PlankDockletItem parent_instance;
	DockyApplicationsDockItemPrivate * priv;
};

struct _DockyApplicationsDockItemClass {
	PlankDockletItemClass parent_class;
};

struct _DockyApplicationsDockItemPrivate {
	GMenuTree* apps_menu;
	GMutex apps_menu_mutex;
	gboolean apps_loaded;
};

struct _Block1Data {
	int _ref_count_;
	DockyApplicationsDockItem* self;
	const gchar* desktop_path;
};

static gint DockyApplicationsDockItem_private_offset;
static gpointer docky_applications_dock_item_parent_class = NULL;

VALA_EXTERN GType docky_applications_dock_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DockyApplicationsDockItem, g_object_unref)
static void docky_applications_dock_item_update_menu (DockyApplicationsDockItem* self);
static void _docky_applications_dock_item_update_menu_gmenu_tree_changed (GMenuTree* _sender,
                                                                   gpointer self);
VALA_EXTERN DockyApplicationsDockItem* docky_applications_dock_item_new_with_dockitem_file (GFile* file);
VALA_EXTERN DockyApplicationsDockItem* docky_applications_dock_item_construct_with_dockitem_file (GType object_type,
                                                                                      GFile* file);
static void* __lambda4_ (DockyApplicationsDockItem* self,
                  GError** error);
static gpointer ___lambda4__plank_task_func (gpointer self,
                                      GError** error);
static PlankAnimationType docky_applications_dock_item_real_on_scrolled (PlankDockElement* base,
                                                                  GdkScrollDirection direction,
                                                                  GdkModifierType mod,
                                                                  guint32 event_time);
static PlankAnimationType docky_applications_dock_item_real_on_clicked (PlankDockElement* base,
                                                                 PlankPopupButton button,
                                                                 GdkModifierType mod,
                                                                 guint32 event_time);
static GeeArrayList* docky_applications_dock_item_real_get_menu_items (PlankDockElement* base);
static void _vala_GMenuTreeDirectory_free (GMenuTreeDirectory* self);
static GtkMenuItem* docky_applications_dock_item_get_submenu_item (DockyApplicationsDockItem* self,
                                                            GMenuTreeDirectory* category);
static void _vala_GMenuTreeIter_free (GMenuTreeIter* self);
static void docky_applications_dock_item_submenu_item_activate (DockyApplicationsDockItem* self,
                                                         GtkMenuItem* item);
static void _docky_applications_dock_item_submenu_item_activate_gtk_menu_item_activate (GtkMenuItem* _sender,
                                                                                 gpointer self);
static gulong* _ulong_dup (gulong* self);
static GMenuTreeDirectory* _vala_GMenuTreeDirectory_copy (GMenuTreeDirectory* self);
static void docky_applications_dock_item_add_menu_items (DockyApplicationsDockItem* self,
                                                  GtkMenu* menu,
                                                  GMenuTreeDirectory* category);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void ____lambda5_ (Block1Data* _data1_);
static void _____lambda5__gtk_menu_item_activate (GtkMenuItem* _sender,
                                           gpointer self);
static void _vala_GMenuTreeEntry_free (GMenuTreeEntry* self);
VALA_EXTERN DockyApplicationsDockItem* docky_applications_dock_item_new (void);
VALA_EXTERN DockyApplicationsDockItem* docky_applications_dock_item_construct (GType object_type);
static GObject * docky_applications_dock_item_constructor (GType type,
                                                    guint n_construct_properties,
                                                    GObjectConstructParam * construct_properties);
static void docky_applications_dock_item_finalize (GObject * obj);
static GType docky_applications_dock_item_get_type_once (void);
static void _vala_clear_GMutex (GMutex * mutex);
static void _vala_clear_GRecMutex (GRecMutex * mutex);
static void _vala_clear_GRWLock (GRWLock * mutex);
static void _vala_clear_GCond (GCond * mutex);

static inline gpointer
docky_applications_dock_item_get_instance_private (DockyApplicationsDockItem* self)
{
	return G_STRUCT_MEMBER_P (self, DockyApplicationsDockItem_private_offset);
}

static void
_docky_applications_dock_item_update_menu_gmenu_tree_changed (GMenuTree* _sender,
                                                              gpointer self)
{
	docky_applications_dock_item_update_menu ((DockyApplicationsDockItem*) self);
}

/**
 * {@inheritDoc}
 */
DockyApplicationsDockItem*
docky_applications_dock_item_construct_with_dockitem_file (GType object_type,
                                                           GFile* file)
{
	DockyApplicationsDockItem * self = NULL;
	PlankDockItemPreferences* _tmp0_;
	PlankDockItemPreferences* _tmp1_;
	g_return_val_if_fail (file != NULL, NULL);
	_tmp0_ = plank_dock_item_preferences_new_with_file (file);
	_tmp1_ = _tmp0_;
	self = (DockyApplicationsDockItem*) g_object_new (object_type, "Prefs", _tmp1_, NULL);
	_g_object_unref0 (_tmp1_);
	return self;
}

DockyApplicationsDockItem*
docky_applications_dock_item_new_with_dockitem_file (GFile* file)
{
	return docky_applications_dock_item_construct_with_dockitem_file (DOCKY_TYPE_APPLICATIONS_DOCK_ITEM, file);
}

static void*
__lambda4_ (DockyApplicationsDockItem* self,
            GError** error)
{
	GError* _inner_error0_ = NULL;
	void* result;
	g_mutex_lock (&self->priv->apps_menu_mutex);
	{
		GMenuTree* _tmp0_;
		_tmp0_ = self->priv->apps_menu;
		gmenu_tree_load_sync (_tmp0_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		self->priv->apps_loaded = TRUE;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_warning ("ApplicationsDockItem.vala:60: Failed to load applications (%s)", _tmp2_);
		self->priv->apps_loaded = FALSE;
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	g_mutex_unlock (&self->priv->apps_menu_mutex);
	result = NULL;
	return result;
}

static gpointer
___lambda4__plank_task_func (gpointer self,
                             GError** error)
{
	gpointer result;
	result = __lambda4_ ((DockyApplicationsDockItem*) self, error);
	return result;
}

static void
docky_applications_dock_item_update_menu (DockyApplicationsDockItem* self)
{
	PlankWorker* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = plank_worker_get_default ();
	plank_worker_add_task_with_result (_tmp0_, G_TYPE_POINTER, NULL, NULL, ___lambda4__plank_task_func, g_object_ref (self), g_object_unref, PLANK_TASK_PRIORITY_HIGH, NULL, NULL);
}

static PlankAnimationType
docky_applications_dock_item_real_on_scrolled (PlankDockElement* base,
                                               GdkScrollDirection direction,
                                               GdkModifierType mod,
                                               guint32 event_time)
{
	DockyApplicationsDockItem * self;
	PlankAnimationType result;
	self = (DockyApplicationsDockItem*) base;
	result = PLANK_ANIMATION_TYPE_NONE;
	return result;
}

static PlankAnimationType
docky_applications_dock_item_real_on_clicked (PlankDockElement* base,
                                              PlankPopupButton button,
                                              GdkModifierType mod,
                                              guint32 event_time)
{
	DockyApplicationsDockItem * self;
	PlankAnimationType result;
	self = (DockyApplicationsDockItem*) base;
	result = PLANK_ANIMATION_TYPE_NONE;
	return result;
}

static void
_vala_GMenuTreeDirectory_free (GMenuTreeDirectory* self)
{
	g_boxed_free (gmenu_tree_directory_get_type (), self);
}

static void
_vala_GMenuTreeIter_free (GMenuTreeIter* self)
{
	g_boxed_free (gmenu_tree_iter_get_type (), self);
}

static GeeArrayList*
docky_applications_dock_item_real_get_menu_items (PlankDockElement* base)
{
	DockyApplicationsDockItem * self;
	GeeArrayList* items = NULL;
	GeeArrayList* _tmp0_;
	GMenuTreeIter* iter = NULL;
	GMenuTree* _tmp4_;
	GMenuTreeDirectory* _tmp5_;
	GMenuTreeDirectory* _tmp6_;
	GMenuTreeIter* _tmp7_;
	GMenuTreeIter* _tmp8_;
	GMenuTreeItemType type = 0;
	GeeArrayList* result;
	self = (DockyApplicationsDockItem*) base;
	_tmp0_ = gee_array_list_new (gtk_menu_item_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	items = _tmp0_;
	if (!self->priv->apps_loaded) {
		GtkMenuItem* item = NULL;
		GtkMenuItem* _tmp1_;
		GeeArrayList* _tmp2_;
		GtkMenuItem* _tmp3_;
		_tmp1_ = plank_dock_element_create_menu_item (_ ("No applications available"), NULL, FALSE);
		item = _tmp1_;
		_tmp2_ = items;
		_tmp3_ = item;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp2_, _tmp3_);
		result = items;
		_g_object_unref0 (item);
		return result;
	}
	_tmp4_ = self->priv->apps_menu;
	_tmp5_ = gmenu_tree_get_root_directory (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = gmenu_tree_directory_iter (_tmp6_);
	_tmp8_ = _tmp7_;
	__vala_GMenuTreeDirectory_free0 (_tmp6_);
	iter = _tmp8_;
	while (TRUE) {
		GMenuTreeIter* _tmp9_;
		GeeArrayList* _tmp10_;
		GMenuTreeIter* _tmp11_;
		GMenuTreeDirectory* _tmp12_;
		GMenuTreeDirectory* _tmp13_;
		GtkMenuItem* _tmp14_;
		GtkMenuItem* _tmp15_;
		_tmp9_ = iter;
		type = gmenu_tree_iter_next (_tmp9_);
		if (!(type != GMENU_TREE_ITEM_INVALID)) {
			break;
		}
		if (type != GMENU_TREE_ITEM_DIRECTORY) {
			continue;
		}
		_tmp10_ = items;
		_tmp11_ = iter;
		_tmp12_ = gmenu_tree_iter_get_directory (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = docky_applications_dock_item_get_submenu_item (self, _tmp13_);
		_tmp15_ = _tmp14_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp15_);
		_g_object_unref0 (_tmp15_);
		__vala_GMenuTreeDirectory_free0 (_tmp13_);
	}
	result = items;
	__vala_GMenuTreeIter_free0 (iter);
	return result;
}

static void
_docky_applications_dock_item_submenu_item_activate_gtk_menu_item_activate (GtkMenuItem* _sender,
                                                                            gpointer self)
{
	docky_applications_dock_item_submenu_item_activate ((DockyApplicationsDockItem*) self, _sender);
}

static gulong*
_ulong_dup (gulong* self)
{
	gulong* dup;
	dup = g_new0 (gulong, 1);
	memcpy (dup, self, sizeof (gulong));
	return dup;
}

static gpointer
__ulong_dup0 (gpointer self)
{
	return self ? _ulong_dup (self) : NULL;
}

static GMenuTreeDirectory*
_vala_GMenuTreeDirectory_copy (GMenuTreeDirectory* self)
{
	return g_boxed_copy (gmenu_tree_directory_get_type (), self);
}

static gpointer
__vala_GMenuTreeDirectory_copy0 (gpointer self)
{
	return self ? _vala_GMenuTreeDirectory_copy (self) : NULL;
}

static GtkMenuItem*
docky_applications_dock_item_get_submenu_item (DockyApplicationsDockItem* self,
                                               GMenuTreeDirectory* category)
{
	gchar* _tmp0_ = NULL;
	GIcon* _tmp1_;
	gchar* _tmp2_;
	GtkMenuItem* item = NULL;
	const gchar* _tmp4_;
	GtkMenuItem* _tmp5_;
	GtkMenu* submenu = NULL;
	GtkMenu* _tmp6_;
	gulong* item_activate_id = NULL;
	gulong _tmp7_;
	gulong _tmp8_;
	gulong* _tmp9_;
	gulong* _tmp10_;
	GMenuTreeDirectory* _tmp11_;
	GtkMenuItem* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (category != NULL, NULL);
	_tmp1_ = gmenu_tree_directory_get_icon (category);
	_tmp2_ = plank_drawing_service_get_icon_from_gicon (_tmp1_);
	_tmp0_ = _tmp2_;
	if (_tmp0_ == NULL) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup ("");
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp3_;
	}
	_tmp4_ = gmenu_tree_directory_get_name (category);
	_tmp5_ = plank_dock_element_create_menu_item (_tmp4_, _tmp0_, TRUE);
	item = _tmp5_;
	_tmp6_ = (GtkMenu*) gtk_menu_new ();
	g_object_ref_sink (_tmp6_);
	submenu = _tmp6_;
	gtk_menu_item_set_submenu (item, submenu);
	gtk_widget_show ((GtkWidget*) submenu);
	gtk_widget_show ((GtkWidget*) item);
	_tmp7_ = g_signal_connect_object (item, "activate", (GCallback) _docky_applications_dock_item_submenu_item_activate_gtk_menu_item_activate, self, 0);
	_tmp8_ = _tmp7_;
	_tmp9_ = __ulong_dup0 (&_tmp8_);
	item_activate_id = _tmp9_;
	_tmp10_ = __ulong_dup0 (item_activate_id);
	g_object_set_data_full ((GObject*) item, "plank-applications-item-activate-id", _tmp10_, g_free);
	_tmp11_ = __vala_GMenuTreeDirectory_copy0 (category);
	g_object_set_data_full ((GObject*) item, "plank-applications-category", _tmp11_, _vala_GMenuTreeDirectory_free);
	result = item;
	_g_free0 (item_activate_id);
	_g_object_unref0 (submenu);
	_g_free0 (_tmp0_);
	return result;
}

static void
docky_applications_dock_item_submenu_item_activate (DockyApplicationsDockItem* self,
                                                    GtkMenuItem* item)
{
	gulong* item_activate_id = NULL;
	gpointer _tmp0_;
	GMenuTreeDirectory* category = NULL;
	gpointer _tmp1_;
	GtkMenu* _tmp2_;
	GtkMenu* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = g_object_steal_data ((GObject*) item, "plank-applications-item-activate-id");
	item_activate_id = (gulong*) _tmp0_;
	g_signal_handler_disconnect (item, *item_activate_id);
	_tmp1_ = g_object_steal_data ((GObject*) item, "plank-applications-category");
	category = (GMenuTreeDirectory*) _tmp1_;
	_tmp2_ = gtk_menu_item_get_submenu (item);
	_tmp3_ = _tmp2_;
	docky_applications_dock_item_add_menu_items (self, _tmp3_, category);
	__vala_GMenuTreeDirectory_free0 (category);
	_g_free0 (item_activate_id);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		DockyApplicationsDockItem* self;
		self = _data1_->self;
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
____lambda5_ (Block1Data* _data1_)
{
	DockyApplicationsDockItem* self;
	PlankSystem* _tmp0_;
	const gchar* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	self = _data1_->self;
	_tmp0_ = plank_system_get_default ();
	_tmp1_ = _data1_->desktop_path;
	_tmp2_ = g_file_new_for_path (_tmp1_);
	_tmp3_ = _tmp2_;
	plank_system_launch (_tmp0_, _tmp3_);
	_g_object_unref0 (_tmp3_);
}

static void
_____lambda5__gtk_menu_item_activate (GtkMenuItem* _sender,
                                      gpointer self)
{
	____lambda5_ (self);
}

static void
_vala_GMenuTreeEntry_free (GMenuTreeEntry* self)
{
	g_boxed_free (gmenu_tree_entry_get_type (), self);
}

static void
docky_applications_dock_item_add_menu_items (DockyApplicationsDockItem* self,
                                             GtkMenu* menu,
                                             GMenuTreeDirectory* category)
{
	GMenuTreeIter* iter = NULL;
	GMenuTreeIter* _tmp0_;
	GMenuTreeItemType type = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (menu != NULL);
	g_return_if_fail (category != NULL);
	_tmp0_ = gmenu_tree_directory_iter (category);
	iter = _tmp0_;
	while (TRUE) {
		GMenuTreeIter* _tmp1_;
		_tmp1_ = iter;
		type = gmenu_tree_iter_next (_tmp1_);
		if (!(type != GMENU_TREE_ITEM_INVALID)) {
			break;
		}
		switch (type) {
			case GMENU_TREE_ITEM_DIRECTORY:
			{
				GMenuTreeIter* _tmp2_;
				GMenuTreeDirectory* _tmp3_;
				GMenuTreeDirectory* _tmp4_;
				GtkMenuItem* _tmp5_;
				GtkMenuItem* _tmp6_;
				_tmp2_ = iter;
				_tmp3_ = gmenu_tree_iter_get_directory (_tmp2_);
				_tmp4_ = _tmp3_;
				_tmp5_ = docky_applications_dock_item_get_submenu_item (self, _tmp4_);
				_tmp6_ = _tmp5_;
				gtk_container_add ((GtkContainer*) menu, (GtkWidget*) _tmp6_);
				_g_object_unref0 (_tmp6_);
				__vala_GMenuTreeDirectory_free0 (_tmp4_);
				break;
			}
			case GMENU_TREE_ITEM_ENTRY:
			{
				Block1Data* _data1_;
				GMenuTreeEntry* entry = NULL;
				GMenuTreeIter* _tmp7_;
				GMenuTreeEntry* _tmp8_;
				GDesktopAppInfo* info = NULL;
				GMenuTreeEntry* _tmp9_;
				GDesktopAppInfo* _tmp10_;
				GMenuTreeEntry* _tmp11_;
				const gchar* _tmp12_;
				gchar* _tmp13_ = NULL;
				GDesktopAppInfo* _tmp14_;
				GIcon* _tmp15_;
				gchar* _tmp16_;
				GtkMenuItem* item = NULL;
				GDesktopAppInfo* _tmp18_;
				const gchar* _tmp19_;
				GtkMenuItem* _tmp20_;
				GtkMenuItem* _tmp21_;
				GtkMenuItem* _tmp22_;
				GtkMenuItem* _tmp23_;
				_data1_ = g_slice_new0 (Block1Data);
				_data1_->_ref_count_ = 1;
				_data1_->self = g_object_ref (self);
				_tmp7_ = iter;
				_tmp8_ = gmenu_tree_iter_get_entry (_tmp7_);
				entry = _tmp8_;
				_tmp9_ = entry;
				_tmp10_ = gmenu_tree_entry_get_app_info (_tmp9_);
				info = _tmp10_;
				_tmp11_ = entry;
				_tmp12_ = gmenu_tree_entry_get_desktop_file_path (_tmp11_);
				_data1_->desktop_path = _tmp12_;
				_tmp14_ = info;
				_tmp15_ = g_app_info_get_icon ((GAppInfo*) _tmp14_);
				_tmp16_ = plank_drawing_service_get_icon_from_gicon (_tmp15_);
				_tmp13_ = _tmp16_;
				if (_tmp13_ == NULL) {
					gchar* _tmp17_;
					_tmp17_ = g_strdup ("");
					_g_free0 (_tmp13_);
					_tmp13_ = _tmp17_;
				}
				_tmp18_ = info;
				_tmp19_ = g_app_info_get_display_name ((GAppInfo*) _tmp18_);
				_tmp20_ = plank_dock_element_create_menu_item (_tmp19_, _tmp13_, TRUE);
				item = _tmp20_;
				_tmp21_ = item;
				g_signal_connect_data (_tmp21_, "activate", (GCallback) _____lambda5__gtk_menu_item_activate, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
				_tmp22_ = item;
				gtk_widget_show ((GtkWidget*) _tmp22_);
				_tmp23_ = item;
				gtk_container_add ((GtkContainer*) menu, (GtkWidget*) _tmp23_);
				_g_object_unref0 (item);
				_g_free0 (_tmp13_);
				__vala_GMenuTreeEntry_free0 (entry);
				block1_data_unref (_data1_);
				_data1_ = NULL;
				break;
			}
			default:
			break;
		}
	}
	__vala_GMenuTreeIter_free0 (iter);
}

DockyApplicationsDockItem*
docky_applications_dock_item_construct (GType object_type)
{
	DockyApplicationsDockItem * self = NULL;
	self = (DockyApplicationsDockItem*) plank_docklet_item_construct (object_type);
	return self;
}

DockyApplicationsDockItem*
docky_applications_dock_item_new (void)
{
	return docky_applications_dock_item_construct (DOCKY_TYPE_APPLICATIONS_DOCK_ITEM);
}

static GObject *
docky_applications_dock_item_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DockyApplicationsDockItem * self;
	GMenuTree* _tmp0_;
	GMenuTree* _tmp1_;
	parent_class = G_OBJECT_CLASS (docky_applications_dock_item_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DOCKY_TYPE_APPLICATIONS_DOCK_ITEM, DockyApplicationsDockItem);
	plank_dock_item_set_Icon ((PlankDockItem*) self, "gnome-applications;;gnome-main-menu");
	plank_dock_element_set_Text ((PlankDockElement*) self, _ ("Applications"));
	_tmp0_ = gmenu_tree_new ("applications.menu", GMENU_TREE_FLAGS_SORT_DISPLAY_NAME);
	_g_object_unref0 (self->priv->apps_menu);
	self->priv->apps_menu = _tmp0_;
	_tmp1_ = self->priv->apps_menu;
	g_signal_connect_object (_tmp1_, "changed", (GCallback) _docky_applications_dock_item_update_menu_gmenu_tree_changed, self, 0);
	docky_applications_dock_item_update_menu (self);
	return obj;
}

static void
docky_applications_dock_item_class_init (DockyApplicationsDockItemClass * klass,
                                         gpointer klass_data)
{
	docky_applications_dock_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DockyApplicationsDockItem_private_offset);
	((PlankDockElementClass *) klass)->on_scrolled = (PlankAnimationType (*) (PlankDockElement*, GdkScrollDirection, GdkModifierType, guint32)) docky_applications_dock_item_real_on_scrolled;
	((PlankDockElementClass *) klass)->on_clicked = (PlankAnimationType (*) (PlankDockElement*, PlankPopupButton, GdkModifierType, guint32)) docky_applications_dock_item_real_on_clicked;
	((PlankDockElementClass *) klass)->get_menu_items = (GeeArrayList* (*) (PlankDockElement*)) docky_applications_dock_item_real_get_menu_items;
	G_OBJECT_CLASS (klass)->constructor = docky_applications_dock_item_constructor;
	G_OBJECT_CLASS (klass)->finalize = docky_applications_dock_item_finalize;
}

static void
docky_applications_dock_item_instance_init (DockyApplicationsDockItem * self,
                                            gpointer klass)
{
	self->priv = docky_applications_dock_item_get_instance_private (self);
}

static void
docky_applications_dock_item_finalize (GObject * obj)
{
	DockyApplicationsDockItem * self;
	GMenuTree* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DOCKY_TYPE_APPLICATIONS_DOCK_ITEM, DockyApplicationsDockItem);
	_tmp0_ = self->priv->apps_menu;
	if (_tmp0_ != NULL) {
		GMenuTree* _tmp1_;
		guint _tmp2_;
		_tmp1_ = self->priv->apps_menu;
		g_signal_parse_name ("changed", gmenu_tree_get_type (), &_tmp2_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _docky_applications_dock_item_update_menu_gmenu_tree_changed, self);
	}
	_g_object_unref0 (self->priv->apps_menu);
	_vala_clear_GMutex (&self->priv->apps_menu_mutex);
	G_OBJECT_CLASS (docky_applications_dock_item_parent_class)->finalize (obj);
}

static GType
docky_applications_dock_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DockyApplicationsDockItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) docky_applications_dock_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DockyApplicationsDockItem), 0, (GInstanceInitFunc) docky_applications_dock_item_instance_init, NULL };
	GType docky_applications_dock_item_type_id;
	docky_applications_dock_item_type_id = g_type_register_static (PLANK_TYPE_DOCKLET_ITEM, "DockyApplicationsDockItem", &g_define_type_info, 0);
	DockyApplicationsDockItem_private_offset = g_type_add_instance_private (docky_applications_dock_item_type_id, sizeof (DockyApplicationsDockItemPrivate));
	return docky_applications_dock_item_type_id;
}

GType
docky_applications_dock_item_get_type (void)
{
	static volatile gsize docky_applications_dock_item_type_id__once = 0;
	if (g_once_init_enter (&docky_applications_dock_item_type_id__once)) {
		GType docky_applications_dock_item_type_id;
		docky_applications_dock_item_type_id = docky_applications_dock_item_get_type_once ();
		g_once_init_leave (&docky_applications_dock_item_type_id__once, docky_applications_dock_item_type_id);
	}
	return docky_applications_dock_item_type_id__once;
}

static void
_vala_clear_GMutex (GMutex * mutex)
{
	GMutex zero_mutex = { 0 };
	if (memcmp (mutex, &zero_mutex, sizeof (GMutex))) {
		g_mutex_clear (mutex);
		memset (mutex, 0, sizeof (GMutex));
	}
}

static void
_vala_clear_GRecMutex (GRecMutex * mutex)
{
	GRecMutex zero_mutex = { 0 };
	if (memcmp (mutex, &zero_mutex, sizeof (GRecMutex))) {
		g_rec_mutex_clear (mutex);
		memset (mutex, 0, sizeof (GRecMutex));
	}
}

static void
_vala_clear_GRWLock (GRWLock * mutex)
{
	GRWLock zero_mutex = { 0 };
	if (memcmp (mutex, &zero_mutex, sizeof (GRWLock))) {
		g_rw_lock_clear (mutex);
		memset (mutex, 0, sizeof (GRWLock));
	}
}

static void
_vala_clear_GCond (GCond * mutex)
{
	GCond zero_mutex = { 0 };
	if (memcmp (mutex, &zero_mutex, sizeof (GCond))) {
		g_cond_clear (mutex);
		memset (mutex, 0, sizeof (GCond));
	}
}

