DbusmenuMenuitem *addMenuItem(DbusmenuMenuitem *parent, int uid, const char * label, int type, int position) {
  // _logmsg(LOG_LEVEL_INFO, "add menu item %s (%d) [p %s]", label, uid, _getItemLabel(parent));

  DbusmenuMenuitem *item = dbusmenu_menuitem_new();

  dbusmenu_menuitem_property_set_int(item, MENUITEM_UID_PROPERTY, uid);
  dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, label);
  if (type == ITEM_SUBMENU)
    dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU);
  else if (type == ITEM_CHECK)
    dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_CHECK);
  else if (type == ITEM_RADIO)
    dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_RADIO);

  dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);

  g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_EVENT, G_CALLBACK(_onItemEvent), NULL);
  g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW, G_CALLBACK(_onItemAboutToShow), NULL);
  // g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER, G_CALLBACK(_onItemShowToUser), NULL);
  g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(_onItemActivated), NULL);
  // g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(_onItemChildAdded), NULL);

  if (parent != NULL) {
    gpointer data = g_object_get_data(G_OBJECT(parent), MENUITEM_JHANDLER_PROPERTY);
    if (data == NULL)
      _logmsg(LOG_LEVEL_ERROR, "parent of item %d hasn't jhandler", uid);
    g_object_set_data(G_OBJECT(item), MENUITEM_JHANDLER_PROPERTY, data);
    if (position < 0)
      dbusmenu_menuitem_child_append(parent, item);
    else
      dbusmenu_menuitem_child_add_position(parent, item, (guint)position);
  }

  return item;
}
DbusmenuMenuitem* addSeparator(DbusmenuMenuitem * parent, int uid, int position) {
  DbusmenuMenuitem* item = dbusmenu_menuitem_new();
  dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TYPE, "separator");
  dbusmenu_menuitem_property_set_int(item, MENUITEM_UID_PROPERTY, uid);
  dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
  if (parent != NULL) {
    if (position < 0)
      dbusmenu_menuitem_child_append(parent, item);
    else
      dbusmenu_menuitem_child_add_position(parent, item, (guint)position);
  }

  return item;
}
static void specific_items_manager_on_root_changed (SpecificItemsManager* self, GObject* newroot) {
	GObject* _tmp0_;
	DbusmenuClient* _tmp19_;
	DbusmenuMenuitem* _tmp20_ = NULL;
	DbusmenuMenuitem* _tmp21_;
	DbusmenuMenuitem* root;
	DbusmenuMenuitem* _tmp22_;
	DbusmenuMenuitem* _tmp23_;
	DbusmenuMenuitem* _tmp24_;
	GList* _tmp25_ = NULL;
	GList* _tmp26_ = NULL;
	GList* children;
	GList* _tmp27_;
	g_return_if_fail (self != NULL);
	_tmp0_ = newroot;
	if (_tmp0_ == NULL) {
		GeeArrayList* _tmp15_;
		GeeArrayList* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		g_debug ("specific-items-manager.vala:70: root disappeared -remove proxyitems");
		{
			GeeArrayList* _tmp1_;
			GeeArrayList* _tmp2_;
			GeeArrayList* _p_list;
			GeeArrayList* _tmp3_;
			gint _tmp4_;
			gint _tmp5_;
			gint _p_size;
			gint _p_index;
			_tmp1_ = self->priv->_proxy_items;
			_tmp2_ = _g_object_ref0 (_tmp1_);
			_p_list = _tmp2_;
			_tmp3_ = _p_list;
			_tmp4_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp3_);
			_tmp5_ = _tmp4_;
			_p_size = _tmp5_;
			_p_index = -1;
			while (TRUE) {
				gint _tmp6_;
				gint _tmp7_;
				gint _tmp8_;
				GeeArrayList* _tmp9_;
				gint _tmp10_;
				gpointer _tmp11_ = NULL;
				DbusmenuMenuitemProxy* p;
				PlayerController* _tmp12_;
				DbusmenuMenuitem* _tmp13_;
				DbusmenuMenuitemProxy* _tmp14_;
				_tmp6_ = _p_index;
				_p_index = _tmp6_ + 1;
				_tmp7_ = _p_index;
				_tmp8_ = _p_size;
				if (!(_tmp7_ < _tmp8_)) {
					break;
				}
				_tmp9_ = _p_list;
				_tmp10_ = _p_index;
				_tmp11_ = gee_abstract_list_get ((GeeAbstractList*) _tmp9_, _tmp10_);
				p = (DbusmenuMenuitemProxy*) _tmp11_;
				_tmp12_ = self->priv->_owner;
				_tmp13_ = _tmp12_->root_menu;
				_tmp14_ = p;
				dbusmenu_menuitem_child_delete (_tmp13_, (DbusmenuMenuitem*) _tmp14_);
				_g_object_unref0 (p);
			}
			_g_object_unref0 (_p_list);
		}
		_tmp15_ = self->priv->_proxy_items;
		gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp15_);
		_tmp16_ = self->priv->_proxy_items;
		_tmp17_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp16_);
		_tmp18_ = _tmp17_;
		g_debug ("specific-items-manager.vala:75: array list size is now %i", _tmp18_);
		return;
	}
	_tmp19_ = self->priv->client;
	_tmp20_ = dbusmenu_client_get_root (_tmp19_);
	_tmp21_ = _g_object_ref0 (_tmp20_);
	root = _tmp21_;
	_tmp22_ = root;
	g_signal_connect_object (_tmp22_, "child-added", (GCallback) _specific_items_manager_on_child_added_dbusmenu_menuitem_child_added, self, 0);
	_tmp23_ = root;
	g_signal_connect_object (_tmp23_, "child-removed", (GCallback) _specific_items_manager_on_child_removed_dbusmenu_menuitem_child_removed, self, 0);
	_tmp24_ = root;
	_tmp25_ = dbusmenu_menuitem_get_children (_tmp24_);
	_tmp26_ = g_list_copy (_tmp25_);
	children = _tmp26_;
	_tmp27_ = children;
	{
		GList* child_collection = NULL;
		GList* child_it = NULL;
		child_collection = _tmp27_;
		for (child_it = child_collection; child_it != NULL; child_it = child_it->next) {
			void* child = NULL;
			child = child_it->data;
			{
				gint _tmp28_ = 0;
				gint pos;
				void* _tmp29_;
				DbusmenuMenuitem* item;
				DbusmenuMenuitem* _tmp30_;
				DbusmenuMenuitemProxy* _tmp31_;
				DbusmenuMenuitemProxy* proxy;
				GeeArrayList* _tmp32_;
				DbusmenuMenuitemProxy* _tmp33_;
				DbusmenuMenuitem* _tmp34_;
				const gchar* _tmp35_ = NULL;
				PlayerController* _tmp36_;
				DbusmenuMenuitem* _tmp37_;
				DbusmenuMenuitemProxy* _tmp38_;
				gint _tmp39_;
				_tmp28_ = specific_items_manager_figure_out_positioning (self);
				pos = _tmp28_;
				_tmp29_ = child;
				item = DBUSMENU_MENUITEM (_tmp29_);
				_tmp30_ = item;
				_tmp31_ = dbusmenu_menuitem_proxy_new (_tmp30_);
				proxy = _tmp31_;
				_tmp32_ = self->priv->_proxy_items;
				_tmp33_ = proxy;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp32_, _tmp33_);
				_tmp34_ = item;
				_tmp35_ = dbusmenu_menuitem_property_get (_tmp34_, DBUSMENU_MENUITEM_PROP_LABEL);
				g_debug ("specific-items-manager.vala:92: Proxy item of label = %s added to coll" \
"ection", _tmp35_);
				_tmp36_ = self->priv->_owner;
				_tmp37_ = _tmp36_->root_menu;
				_tmp38_ = proxy;
				_tmp39_ = pos;
				dbusmenu_menuitem_child_add_position (_tmp37_, (DbusmenuMenuitem*) _tmp38_, (guint) _tmp39_);
				_g_object_unref0 (proxy);
			}
		}
	}
	_g_list_free0 (children);
	_g_object_unref0 (root);
}