/**
 * shell_app_info_get_section:
 *
 * return name of section, that contain this application.
 * Returns: (transfer full): section name
 */
char *
shell_app_info_get_section (ShellAppInfo *info)
{
  char *name;
  GMenuTreeDirectory *dir, *parent;

  if (info->type != SHELL_APP_INFO_TYPE_ENTRY)
    return NULL;

  dir = gmenu_tree_item_get_parent ((GMenuTreeItem*)info->entry);
  if (!dir)
    return NULL;

  parent = gmenu_tree_item_get_parent ((GMenuTreeItem*)dir);
  if (!parent)
    return NULL;

  while (TRUE)
    {
      GMenuTreeDirectory *pparent = gmenu_tree_item_get_parent ((GMenuTreeItem*)parent);
      if (!pparent)
        break;
      gmenu_tree_item_unref ((GMenuTreeItem*)dir);
      dir = parent;
      parent = pparent;
    }

  name = g_strdup (gmenu_tree_directory_get_name (dir));

  gmenu_tree_item_unref ((GMenuTreeItem*)dir);
  gmenu_tree_item_unref ((GMenuTreeItem*)parent);
  return name;
}
Пример #2
0
static void
append_directory_path(GMenuTreeDirectory *directory,
                      GString            *path)
{
  GMenuTreeDirectory *parent;

  parent = gmenu_tree_item_get_parent(GMENU_TREE_ITEM(directory));

  if (!parent)
  {
    g_string_append_c(path, '/');
    return;
  }

  append_directory_path(parent, path);

  g_string_append(path, gmenu_tree_directory_get_name(directory));
  g_string_append_c(path, '/');

  gmenu_tree_item_unref(parent);
}