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

/*///////////////////////////////////////////////////////////////////////*/
/* Copyright 2011-2021 Simon Schneegans*/
/**/
/* Permission is hereby granted, free of charge, to any person obtaining*/
/* a copy of this software and associated documentation files (the*/
/* "Software"), to deal in the Software without restriction, including*/
/* without limitation the rights to use, copy, modify, merge, publish,*/
/* distribute, sublicense, and/or sell copies of the Software, and to*/
/* permit persons to whom the Software is furnished to do so, subject to*/
/* the following conditions:*/
/* */
/* The above copyright notice and this permission notice shall be*/
/* included in all copies or substantial portions of the Software.*/
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,*/
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF*/
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY*/
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,*/
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE*/
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
/*///////////////////////////////////////////////////////////////////////*/

#include <glib-object.h>
#include <libxml/xmlwriter.h>
#include <libxml/tree.h>
#include <glib.h>
#include <gmenu-tree.h>
#include <gee.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.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 GNOME_PIE_TYPE_ACTION_GROUP (gnome_pie_action_group_get_type ())
#define GNOME_PIE_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_ACTION_GROUP, GnomePieActionGroup))
#define GNOME_PIE_ACTION_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_ACTION_GROUP, GnomePieActionGroupClass))
#define GNOME_PIE_IS_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_ACTION_GROUP))
#define GNOME_PIE_IS_ACTION_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_ACTION_GROUP))
#define GNOME_PIE_ACTION_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_ACTION_GROUP, GnomePieActionGroupClass))

typedef struct _GnomePieActionGroup GnomePieActionGroup;
typedef struct _GnomePieActionGroupClass GnomePieActionGroupClass;
typedef struct _GnomePieActionGroupPrivate GnomePieActionGroupPrivate;

#define GNOME_PIE_TYPE_MENU_GROUP (gnome_pie_menu_group_get_type ())
#define GNOME_PIE_MENU_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_MENU_GROUP, GnomePieMenuGroup))
#define GNOME_PIE_MENU_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_MENU_GROUP, GnomePieMenuGroupClass))
#define GNOME_PIE_IS_MENU_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_MENU_GROUP))
#define GNOME_PIE_IS_MENU_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_MENU_GROUP))
#define GNOME_PIE_MENU_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_MENU_GROUP, GnomePieMenuGroupClass))

typedef struct _GnomePieMenuGroup GnomePieMenuGroup;
typedef struct _GnomePieMenuGroupClass GnomePieMenuGroupClass;
typedef struct _GnomePieMenuGroupPrivate GnomePieMenuGroupPrivate;
enum  {
	GNOME_PIE_MENU_GROUP_0_PROPERTY,
	GNOME_PIE_MENU_GROUP_IS_TOPLEVEL_PROPERTY,
	GNOME_PIE_MENU_GROUP_NUM_PROPERTIES
};
static GParamSpec* gnome_pie_menu_group_properties[GNOME_PIE_MENU_GROUP_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GNOME_PIE_GROUP_REGISTRY_TYPE_TYPEDESCRIPTION (gnome_pie_group_registry_typedescription_get_type ())
#define GNOME_PIE_GROUP_REGISTRY_TYPEDESCRIPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_GROUP_REGISTRY_TYPE_TYPEDESCRIPTION, GnomePieGroupRegistryTypeDescription))
#define GNOME_PIE_GROUP_REGISTRY_TYPEDESCRIPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_GROUP_REGISTRY_TYPE_TYPEDESCRIPTION, GnomePieGroupRegistryTypeDescriptionClass))
#define GNOME_PIE_GROUP_REGISTRY_IS_TYPEDESCRIPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_GROUP_REGISTRY_TYPE_TYPEDESCRIPTION))
#define GNOME_PIE_GROUP_REGISTRY_IS_TYPEDESCRIPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_GROUP_REGISTRY_TYPE_TYPEDESCRIPTION))
#define GNOME_PIE_GROUP_REGISTRY_TYPEDESCRIPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_GROUP_REGISTRY_TYPE_TYPEDESCRIPTION, GnomePieGroupRegistryTypeDescriptionClass))

typedef struct _GnomePieGroupRegistryTypeDescription GnomePieGroupRegistryTypeDescription;
typedef struct _GnomePieGroupRegistryTypeDescriptionClass GnomePieGroupRegistryTypeDescriptionClass;
#define __vala_GMenuTreeDirectory_free0(var) ((var == NULL) ? NULL : (var = (_vala_GMenuTreeDirectory_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define GNOME_PIE_TYPE_PIE (gnome_pie_pie_get_type ())
#define GNOME_PIE_PIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_PIE, GnomePiePie))
#define GNOME_PIE_PIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_PIE, GnomePiePieClass))
#define GNOME_PIE_IS_PIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_PIE))
#define GNOME_PIE_IS_PIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_PIE))
#define GNOME_PIE_PIE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_PIE, GnomePiePieClass))

typedef struct _GnomePiePie GnomePiePie;
typedef struct _GnomePiePieClass GnomePiePieClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define GNOME_PIE_TYPE_ACTION (gnome_pie_action_get_type ())
#define GNOME_PIE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_ACTION, GnomePieAction))
#define GNOME_PIE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_ACTION, GnomePieActionClass))
#define GNOME_PIE_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_ACTION))
#define GNOME_PIE_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_ACTION))
#define GNOME_PIE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_ACTION, GnomePieActionClass))

typedef struct _GnomePieAction GnomePieAction;
typedef struct _GnomePieActionClass GnomePieActionClass;

#define GNOME_PIE_TYPE_PIE_ACTION (gnome_pie_pie_action_get_type ())
#define GNOME_PIE_PIE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_PIE_TYPE_PIE_ACTION, GnomePiePieAction))
#define GNOME_PIE_PIE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_PIE_TYPE_PIE_ACTION, GnomePiePieActionClass))
#define GNOME_PIE_IS_PIE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_PIE_TYPE_PIE_ACTION))
#define GNOME_PIE_IS_PIE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_PIE_TYPE_PIE_ACTION))
#define GNOME_PIE_PIE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_PIE_TYPE_PIE_ACTION, GnomePiePieActionClass))

typedef struct _GnomePiePieAction GnomePiePieAction;
typedef struct _GnomePiePieActionClass GnomePiePieActionClass;
#define __vala_GMenuTreeEntry_free0(var) ((var == NULL) ? NULL : (var = (_vala_GMenuTreeEntry_free (var), NULL)))
#define __vala_GMenuTreeIter_free0(var) ((var == NULL) ? NULL : (var = (_vala_GMenuTreeIter_free (var), NULL)))

struct _GnomePieActionGroup {
	GObject parent_instance;
	GnomePieActionGroupPrivate * priv;
};

struct _GnomePieActionGroupClass {
	GObjectClass parent_class;
	void (*on_remove) (GnomePieActionGroup* self);
	void (*on_save) (GnomePieActionGroup* self, xmlTextWriter* writer);
	void (*on_load) (GnomePieActionGroup* self, xmlNode* data);
};

struct _GnomePieMenuGroup {
	GnomePieActionGroup parent_instance;
	GnomePieMenuGroupPrivate * priv;
};

struct _GnomePieMenuGroupClass {
	GnomePieActionGroupClass parent_class;
};

struct _GnomePieMenuGroupPrivate {
	gboolean _is_toplevel;
	GMenuTree* menu;
	GeeArrayList* childs;
	gboolean changing;
	gboolean changed_again;
};

static gint GnomePieMenuGroup_private_offset;
static gpointer gnome_pie_menu_group_parent_class = NULL;

VALA_EXTERN GType gnome_pie_action_group_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieActionGroup, g_object_unref)
VALA_EXTERN GType gnome_pie_menu_group_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieMenuGroup, g_object_unref)
VALA_EXTERN void gnome_pie_action_group_on_remove (GnomePieActionGroup* self);
VALA_EXTERN gpointer gnome_pie_group_registry_typedescription_ref (gpointer instance);
VALA_EXTERN void gnome_pie_group_registry_typedescription_unref (gpointer instance);
VALA_EXTERN GParamSpec* gnome_pie_group_registry_param_spec_typedescription (const gchar* name,
                                                                 const gchar* nick,
                                                                 const gchar* blurb,
                                                                 GType object_type,
                                                                 GParamFlags flags);
VALA_EXTERN void gnome_pie_group_registry_value_set_typedescription (GValue* value,
                                                         gpointer v_object);
VALA_EXTERN void gnome_pie_group_registry_value_take_typedescription (GValue* value,
                                                          gpointer v_object);
VALA_EXTERN gpointer gnome_pie_group_registry_value_get_typedescription (const GValue* value);
VALA_EXTERN GType gnome_pie_group_registry_typedescription_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieGroupRegistryTypeDescription, gnome_pie_group_registry_typedescription_unref)
VALA_EXTERN GnomePieGroupRegistryTypeDescription* gnome_pie_menu_group_register (void);
VALA_EXTERN GnomePieGroupRegistryTypeDescription* gnome_pie_group_registry_typedescription_new (void);
VALA_EXTERN GnomePieGroupRegistryTypeDescription* gnome_pie_group_registry_typedescription_construct (GType object_type);
VALA_EXTERN void gnome_pie_group_registry_typedescription_set_name (GnomePieGroupRegistryTypeDescription* self,
                                                        const gchar* value);
VALA_EXTERN void gnome_pie_group_registry_typedescription_set_icon (GnomePieGroupRegistryTypeDescription* self,
                                                        const gchar* value);
VALA_EXTERN void gnome_pie_group_registry_typedescription_set_description (GnomePieGroupRegistryTypeDescription* self,
                                                               const gchar* value);
VALA_EXTERN void gnome_pie_group_registry_typedescription_set_id (GnomePieGroupRegistryTypeDescription* self,
                                                      const gchar* value);
VALA_EXTERN GnomePieMenuGroup* gnome_pie_menu_group_new (const gchar* parent_id);
VALA_EXTERN GnomePieMenuGroup* gnome_pie_menu_group_construct (GType object_type,
                                                   const gchar* parent_id);
VALA_EXTERN GnomePieMenuGroup* gnome_pie_menu_group_new_sub_menu (const gchar* parent_id);
VALA_EXTERN GnomePieMenuGroup* gnome_pie_menu_group_construct_sub_menu (GType object_type,
                                                            const gchar* parent_id);
static void gnome_pie_menu_group_load_toplevel (GnomePieMenuGroup* self);
static void gnome_pie_menu_group_load_contents (GnomePieMenuGroup* self,
                                         GMenuTreeDirectory* dir,
                                         const gchar* parent_id);
VALA_EXTERN const gchar* gnome_pie_action_group_get_parent_id (GnomePieActionGroup* self);
static void _vala_GMenuTreeDirectory_free (GMenuTreeDirectory* self);
VALA_EXTERN GType gnome_pie_pie_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePiePie, g_object_unref)
VALA_EXTERN GnomePiePie* gnome_pie_pie_manager_create_dynamic_pie (const gchar* name,
                                                       const gchar* icon_name,
                                                       const gchar* desired_id);
VALA_EXTERN const gchar* gnome_pie_pie_get_id (GnomePiePie* self);
VALA_EXTERN GType gnome_pie_action_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePieAction, g_object_unref)
VALA_EXTERN void gnome_pie_action_group_add_action (GnomePieActionGroup* self,
                                        GnomePieAction* new_action);
VALA_EXTERN GnomePiePieAction* gnome_pie_pie_action_new (const gchar* id,
                                             gboolean is_quickaction);
VALA_EXTERN GnomePiePieAction* gnome_pie_pie_action_construct (GType object_type,
                                                   const gchar* id,
                                                   gboolean is_quickaction);
VALA_EXTERN GType gnome_pie_pie_action_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GnomePiePieAction, g_object_unref)
VALA_EXTERN void gnome_pie_pie_add_group (GnomePiePie* self,
                              GnomePieActionGroup* group,
                              gint at_position);
static void _vala_GMenuTreeEntry_free (GMenuTreeEntry* self);
VALA_EXTERN GnomePieAction* gnome_pie_action_registry_new_for_app_info (GAppInfo* info);
static void _vala_GMenuTreeIter_free (GMenuTreeIter* self);
static void gnome_pie_menu_group_reload (GnomePieMenuGroup* self);
static gboolean ___lambda23_ (GnomePieMenuGroup* self);
static void gnome_pie_menu_group_clear (GnomePieMenuGroup* self);
static gboolean ____lambda23__gsource_func (gpointer self);
static void gnome_pie_menu_group_real_on_remove (GnomePieActionGroup* base);
VALA_EXTERN gboolean gnome_pie_menu_group_get_is_toplevel (GnomePieMenuGroup* self);
VALA_EXTERN void gnome_pie_pie_manager_remove_pie (const gchar* id);
VALA_EXTERN void gnome_pie_action_group_delete_all (GnomePieActionGroup* self);
VALA_EXTERN void gnome_pie_menu_group_set_is_toplevel (GnomePieMenuGroup* self,
                                           gboolean value);
static GObject * gnome_pie_menu_group_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void _gnome_pie_menu_group_reload_gmenu_tree_changed (GMenuTree* _sender,
                                                      gpointer self);
static void gnome_pie_menu_group_finalize (GObject * obj);
static GType gnome_pie_menu_group_get_type_once (void);
static void _vala_gnome_pie_menu_group_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_gnome_pie_menu_group_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);

static inline gpointer
gnome_pie_menu_group_get_instance_private (GnomePieMenuGroup* self)
{
	return G_STRUCT_MEMBER_P (self, GnomePieMenuGroup_private_offset);
}

GnomePieGroupRegistryTypeDescription*
gnome_pie_menu_group_register (void)
{
	GnomePieGroupRegistryTypeDescription* description = NULL;
	GnomePieGroupRegistryTypeDescription* _tmp0_;
	GnomePieGroupRegistryTypeDescription* result;
	_tmp0_ = gnome_pie_group_registry_typedescription_new ();
	description = _tmp0_;
	gnome_pie_group_registry_typedescription_set_name (description, _ ("Group: Main menu"));
	gnome_pie_group_registry_typedescription_set_icon (description, "start-here");
	gnome_pie_group_registry_typedescription_set_description (description, _ ("Displays your main menu structure."));
	gnome_pie_group_registry_typedescription_set_id (description, "menu");
	result = description;
	return result;
}

GnomePieMenuGroup*
gnome_pie_menu_group_construct (GType object_type,
                                const gchar* parent_id)
{
	GnomePieMenuGroup * self = NULL;
	g_return_val_if_fail (parent_id != NULL, NULL);
	self = (GnomePieMenuGroup*) g_object_new (object_type, "parent-id", parent_id, "is-toplevel", TRUE, NULL);
	return self;
}

GnomePieMenuGroup*
gnome_pie_menu_group_new (const gchar* parent_id)
{
	return gnome_pie_menu_group_construct (GNOME_PIE_TYPE_MENU_GROUP, parent_id);
}

GnomePieMenuGroup*
gnome_pie_menu_group_construct_sub_menu (GType object_type,
                                         const gchar* parent_id)
{
	GnomePieMenuGroup * self = NULL;
	g_return_val_if_fail (parent_id != NULL, NULL);
	self = (GnomePieMenuGroup*) g_object_new (object_type, "parent-id", parent_id, "is-toplevel", FALSE, NULL);
	return self;
}

GnomePieMenuGroup*
gnome_pie_menu_group_new_sub_menu (const gchar* parent_id)
{
	return gnome_pie_menu_group_construct_sub_menu (GNOME_PIE_TYPE_MENU_GROUP, parent_id);
}

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

static void
gnome_pie_menu_group_load_toplevel (GnomePieMenuGroup* self)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		gboolean _tmp0_ = FALSE;
		GMenuTree* _tmp1_;
		_tmp1_ = self->priv->menu;
		_tmp0_ = gmenu_tree_load_sync (_tmp1_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (_tmp0_) {
			GMenuTree* _tmp2_;
			GMenuTreeDirectory* _tmp3_;
			GMenuTreeDirectory* _tmp4_;
			const gchar* _tmp5_;
			const gchar* _tmp6_;
			_tmp2_ = self->priv->menu;
			_tmp3_ = gmenu_tree_get_root_directory (_tmp2_);
			_tmp4_ = _tmp3_;
			_tmp5_ = gnome_pie_action_group_get_parent_id ((GnomePieActionGroup*) self);
			_tmp6_ = _tmp5_;
			gnome_pie_menu_group_load_contents (self, _tmp4_, _tmp6_);
			__vala_GMenuTreeDirectory_free0 (_tmp4_);
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		const gchar* _tmp8_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp7_ = e;
		_tmp8_ = _tmp7_->message;
		g_warning ("menuGroup.vala:115: %s", _tmp8_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

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

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

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

static void
gnome_pie_menu_group_load_contents (GnomePieMenuGroup* self,
                                    GMenuTreeDirectory* dir,
                                    const gchar* parent_id)
{
	GMenuTreeIter* item = NULL;
	GMenuTreeIter* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (dir != NULL);
	g_return_if_fail (parent_id != NULL);
	_tmp0_ = gmenu_tree_directory_iter (dir);
	item = _tmp0_;
	while (TRUE) {
		GMenuTreeItemType type = 0;
		GMenuTreeIter* _tmp1_;
		gboolean _tmp2_ = FALSE;
		_tmp1_ = item;
		type = gmenu_tree_iter_next (_tmp1_);
		if (type == GMENU_TREE_ITEM_INVALID) {
			break;
		}
		if (type == GMENU_TREE_ITEM_DIRECTORY) {
			GMenuTreeIter* _tmp3_;
			GMenuTreeDirectory* _tmp4_;
			GMenuTreeDirectory* _tmp5_;
			_tmp3_ = item;
			_tmp4_ = gmenu_tree_iter_get_directory (_tmp3_);
			_tmp5_ = _tmp4_;
			_tmp2_ = !gmenu_tree_directory_get_is_nodisplay (_tmp5_);
			__vala_GMenuTreeDirectory_free0 (_tmp5_);
		} else {
			_tmp2_ = FALSE;
		}
		if (_tmp2_) {
			GIcon* icon = NULL;
			GMenuTreeIter* _tmp6_;
			GMenuTreeDirectory* _tmp7_;
			GMenuTreeDirectory* _tmp8_;
			GIcon* _tmp9_;
			GIcon* _tmp10_;
			GIcon* _tmp11_;
			GnomePiePie* sub_menu = NULL;
			GMenuTreeIter* _tmp12_;
			GMenuTreeDirectory* _tmp13_;
			GMenuTreeDirectory* _tmp14_;
			const gchar* _tmp15_;
			GIcon* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			GnomePiePie* _tmp19_;
			GnomePiePie* _tmp20_;
			GnomePieMenuGroup* group = NULL;
			GnomePiePie* _tmp21_;
			const gchar* _tmp22_;
			const gchar* _tmp23_;
			GnomePieMenuGroup* _tmp24_;
			GnomePieMenuGroup* _tmp25_;
			GnomePiePieAction* _tmp26_;
			GnomePiePieAction* _tmp27_;
			GnomePieMenuGroup* _tmp28_;
			GMenuTreeIter* _tmp29_;
			GMenuTreeDirectory* _tmp30_;
			GMenuTreeDirectory* _tmp31_;
			GnomePiePie* _tmp32_;
			const gchar* _tmp33_;
			const gchar* _tmp34_;
			GeeArrayList* _tmp35_;
			GnomePieMenuGroup* _tmp36_;
			GnomePiePie* _tmp37_;
			GnomePieMenuGroup* _tmp38_;
			GnomePiePie* _tmp39_;
			const gchar* _tmp40_;
			const gchar* _tmp41_;
			GnomePiePieAction* _tmp42_;
			GnomePiePieAction* _tmp43_;
			_tmp6_ = item;
			_tmp7_ = gmenu_tree_iter_get_directory (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = gmenu_tree_directory_get_icon (_tmp8_);
			_tmp10_ = _g_object_ref0 (_tmp9_);
			_tmp11_ = _tmp10_;
			__vala_GMenuTreeDirectory_free0 (_tmp8_);
			icon = _tmp11_;
			_tmp12_ = item;
			_tmp13_ = gmenu_tree_iter_get_directory (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp15_ = gmenu_tree_directory_get_name (_tmp14_);
			_tmp16_ = icon;
			_tmp17_ = g_icon_to_string (_tmp16_);
			_tmp18_ = _tmp17_;
			_tmp19_ = gnome_pie_pie_manager_create_dynamic_pie (_tmp15_, _tmp18_, NULL);
			_tmp20_ = _tmp19_;
			_g_free0 (_tmp18_);
			__vala_GMenuTreeDirectory_free0 (_tmp14_);
			sub_menu = _tmp20_;
			_tmp21_ = sub_menu;
			_tmp22_ = gnome_pie_pie_get_id (_tmp21_);
			_tmp23_ = _tmp22_;
			_tmp24_ = gnome_pie_menu_group_new_sub_menu (_tmp23_);
			group = _tmp24_;
			_tmp25_ = group;
			_tmp26_ = gnome_pie_pie_action_new (parent_id, TRUE);
			_tmp27_ = _tmp26_;
			gnome_pie_action_group_add_action ((GnomePieActionGroup*) _tmp25_, (GnomePieAction*) _tmp27_);
			_g_object_unref0 (_tmp27_);
			_tmp28_ = group;
			_tmp29_ = item;
			_tmp30_ = gmenu_tree_iter_get_directory (_tmp29_);
			_tmp31_ = _tmp30_;
			_tmp32_ = sub_menu;
			_tmp33_ = gnome_pie_pie_get_id (_tmp32_);
			_tmp34_ = _tmp33_;
			gnome_pie_menu_group_load_contents (_tmp28_, _tmp31_, _tmp34_);
			__vala_GMenuTreeDirectory_free0 (_tmp31_);
			_tmp35_ = self->priv->childs;
			_tmp36_ = group;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp35_, _tmp36_);
			_tmp37_ = sub_menu;
			_tmp38_ = group;
			gnome_pie_pie_add_group (_tmp37_, (GnomePieActionGroup*) _tmp38_, -1);
			_tmp39_ = sub_menu;
			_tmp40_ = gnome_pie_pie_get_id (_tmp39_);
			_tmp41_ = _tmp40_;
			_tmp42_ = gnome_pie_pie_action_new (_tmp41_, FALSE);
			_tmp43_ = _tmp42_;
			gnome_pie_action_group_add_action ((GnomePieActionGroup*) self, (GnomePieAction*) _tmp43_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (group);
			_g_object_unref0 (sub_menu);
			_g_object_unref0 (icon);
		} else {
			if (type == GMENU_TREE_ITEM_ENTRY) {
				GMenuTreeIter* _tmp44_;
				GMenuTreeEntry* _tmp45_;
				GMenuTreeEntry* _tmp46_;
				gboolean _tmp47_;
				_tmp44_ = item;
				_tmp45_ = gmenu_tree_iter_get_entry (_tmp44_);
				_tmp46_ = _tmp45_;
				_tmp47_ = !gmenu_tree_entry_get_is_excluded (_tmp46_);
				__vala_GMenuTreeEntry_free0 (_tmp46_);
				if (_tmp47_) {
					GMenuTreeIter* _tmp48_;
					GMenuTreeEntry* _tmp49_;
					GMenuTreeEntry* _tmp50_;
					GDesktopAppInfo* _tmp51_;
					GnomePieAction* _tmp52_;
					GnomePieAction* _tmp53_;
					_tmp48_ = item;
					_tmp49_ = gmenu_tree_iter_get_entry (_tmp48_);
					_tmp50_ = _tmp49_;
					_tmp51_ = gmenu_tree_entry_get_app_info (_tmp50_);
					_tmp52_ = gnome_pie_action_registry_new_for_app_info ((GAppInfo*) _tmp51_);
					_tmp53_ = _tmp52_;
					gnome_pie_action_group_add_action ((GnomePieActionGroup*) self, _tmp53_);
					_g_object_unref0 (_tmp53_);
					__vala_GMenuTreeEntry_free0 (_tmp50_);
				}
			}
		}
	}
	__vala_GMenuTreeIter_free0 (item);
}

static gboolean
___lambda23_ (GnomePieMenuGroup* self)
{
	gboolean result;
	if (self->priv->changed_again) {
		self->priv->changed_again = FALSE;
		result = TRUE;
		return result;
	}
	g_message ("menuGroup.vala:210: Main menu changed...");
	gnome_pie_menu_group_clear (self);
	gnome_pie_menu_group_load_toplevel (self);
	self->priv->changing = FALSE;
	result = FALSE;
	return result;
}

static gboolean
____lambda23__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda23_ ((GnomePieMenuGroup*) self);
	return result;
}

static void
gnome_pie_menu_group_reload (GnomePieMenuGroup* self)
{
	g_return_if_fail (self != NULL);
	if (!self->priv->changing) {
		self->priv->changing = TRUE;
		g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 500, ____lambda23__gsource_func, g_object_ref (self), g_object_unref);
	} else {
		self->priv->changed_again = TRUE;
	}
}

static void
gnome_pie_menu_group_real_on_remove (GnomePieActionGroup* base)
{
	GnomePieMenuGroup * self;
	gboolean _tmp0_;
	self = (GnomePieMenuGroup*) base;
	_tmp0_ = self->priv->_is_toplevel;
	if (_tmp0_) {
		gnome_pie_menu_group_clear (self);
	}
}

static void
gnome_pie_menu_group_clear (GnomePieMenuGroup* self)
{
	gboolean _tmp9_;
	GeeArrayList* _tmp12_;
	g_return_if_fail (self != NULL);
	{
		GeeArrayList* _child_list = NULL;
		GeeArrayList* _tmp0_;
		gint _child_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _child_index = 0;
		_tmp0_ = self->priv->childs;
		_child_list = _tmp0_;
		_tmp1_ = _child_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_child_size = _tmp3_;
		_child_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			GnomePieMenuGroup* child = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			GnomePieMenuGroup* _tmp8_;
			_child_index = _child_index + 1;
			_tmp4_ = _child_index;
			_tmp5_ = _child_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _child_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _child_index);
			child = (GnomePieMenuGroup*) _tmp7_;
			_tmp8_ = child;
			gnome_pie_menu_group_clear (_tmp8_);
			_g_object_unref0 (child);
		}
	}
	_tmp9_ = self->priv->_is_toplevel;
	if (!_tmp9_) {
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		_tmp10_ = gnome_pie_action_group_get_parent_id ((GnomePieActionGroup*) self);
		_tmp11_ = _tmp10_;
		gnome_pie_pie_manager_remove_pie (_tmp11_);
	}
	gnome_pie_action_group_delete_all ((GnomePieActionGroup*) self);
	_tmp12_ = self->priv->childs;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp12_);
}

gboolean
gnome_pie_menu_group_get_is_toplevel (GnomePieMenuGroup* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_toplevel;
	return result;
}

void
gnome_pie_menu_group_set_is_toplevel (GnomePieMenuGroup* self,
                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = gnome_pie_menu_group_get_is_toplevel (self);
	if (old_value != value) {
		self->priv->_is_toplevel = value;
		g_object_notify_by_pspec ((GObject *) self, gnome_pie_menu_group_properties[GNOME_PIE_MENU_GROUP_IS_TOPLEVEL_PROPERTY]);
	}
}

static void
_gnome_pie_menu_group_reload_gmenu_tree_changed (GMenuTree* _sender,
                                                 gpointer self)
{
	gnome_pie_menu_group_reload ((GnomePieMenuGroup*) self);
}

static GObject *
gnome_pie_menu_group_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GnomePieMenuGroup * self;
	GeeArrayList* _tmp0_;
	gboolean _tmp1_;
	parent_class = G_OBJECT_CLASS (gnome_pie_menu_group_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GNOME_PIE_TYPE_MENU_GROUP, GnomePieMenuGroup);
	_tmp0_ = gee_array_list_new (GNOME_PIE_TYPE_MENU_GROUP, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->childs);
	self->priv->childs = _tmp0_;
	_tmp1_ = self->priv->_is_toplevel;
	if (_tmp1_) {
		GMenuTree* _tmp2_;
		GMenuTree* _tmp3_;
		_tmp2_ = gmenu_tree_new ("applications.menu", GMENU_TREE_FLAGS_INCLUDE_EXCLUDED);
		_g_object_unref0 (self->priv->menu);
		self->priv->menu = _tmp2_;
		_tmp3_ = self->priv->menu;
		g_signal_connect_object (_tmp3_, "changed", (GCallback) _gnome_pie_menu_group_reload_gmenu_tree_changed, self, 0);
		gnome_pie_menu_group_load_toplevel (self);
	}
	return obj;
}

static void
gnome_pie_menu_group_class_init (GnomePieMenuGroupClass * klass,
                                 gpointer klass_data)
{
	gnome_pie_menu_group_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GnomePieMenuGroup_private_offset);
	((GnomePieActionGroupClass *) klass)->on_remove = (void (*) (GnomePieActionGroup*)) gnome_pie_menu_group_real_on_remove;
	G_OBJECT_CLASS (klass)->get_property = _vala_gnome_pie_menu_group_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gnome_pie_menu_group_set_property;
	G_OBJECT_CLASS (klass)->constructor = gnome_pie_menu_group_constructor;
	G_OBJECT_CLASS (klass)->finalize = gnome_pie_menu_group_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GNOME_PIE_MENU_GROUP_IS_TOPLEVEL_PROPERTY, gnome_pie_menu_group_properties[GNOME_PIE_MENU_GROUP_IS_TOPLEVEL_PROPERTY] = g_param_spec_boolean ("is-toplevel", "is-toplevel", "is-toplevel", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
gnome_pie_menu_group_instance_init (GnomePieMenuGroup * self,
                                    gpointer klass)
{
	self->priv = gnome_pie_menu_group_get_instance_private (self);
	self->priv->_is_toplevel = TRUE;
	self->priv->menu = NULL;
	self->priv->changing = FALSE;
	self->priv->changed_again = FALSE;
}

static void
gnome_pie_menu_group_finalize (GObject * obj)
{
	GnomePieMenuGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GNOME_PIE_TYPE_MENU_GROUP, GnomePieMenuGroup);
	_g_object_unref0 (self->priv->menu);
	_g_object_unref0 (self->priv->childs);
	G_OBJECT_CLASS (gnome_pie_menu_group_parent_class)->finalize (obj);
}

static GType
gnome_pie_menu_group_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GnomePieMenuGroupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gnome_pie_menu_group_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GnomePieMenuGroup), 0, (GInstanceInitFunc) gnome_pie_menu_group_instance_init, NULL };
	GType gnome_pie_menu_group_type_id;
	gnome_pie_menu_group_type_id = g_type_register_static (GNOME_PIE_TYPE_ACTION_GROUP, "GnomePieMenuGroup", &g_define_type_info, 0);
	GnomePieMenuGroup_private_offset = g_type_add_instance_private (gnome_pie_menu_group_type_id, sizeof (GnomePieMenuGroupPrivate));
	return gnome_pie_menu_group_type_id;
}

GType
gnome_pie_menu_group_get_type (void)
{
	static volatile gsize gnome_pie_menu_group_type_id__once = 0;
	if (g_once_init_enter (&gnome_pie_menu_group_type_id__once)) {
		GType gnome_pie_menu_group_type_id;
		gnome_pie_menu_group_type_id = gnome_pie_menu_group_get_type_once ();
		g_once_init_leave (&gnome_pie_menu_group_type_id__once, gnome_pie_menu_group_type_id);
	}
	return gnome_pie_menu_group_type_id__once;
}

static void
_vala_gnome_pie_menu_group_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	GnomePieMenuGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GNOME_PIE_TYPE_MENU_GROUP, GnomePieMenuGroup);
	switch (property_id) {
		case GNOME_PIE_MENU_GROUP_IS_TOPLEVEL_PROPERTY:
		g_value_set_boolean (value, gnome_pie_menu_group_get_is_toplevel (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gnome_pie_menu_group_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	GnomePieMenuGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GNOME_PIE_TYPE_MENU_GROUP, GnomePieMenuGroup);
	switch (property_id) {
		case GNOME_PIE_MENU_GROUP_IS_TOPLEVEL_PROPERTY:
		gnome_pie_menu_group_set_is_toplevel (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

