static void
gb_project_tree_actions_refresh (GSimpleAction *action,
                                 GVariant      *variant,
                                 gpointer       user_data)
{
  GbProjectTree *self = user_data;
  IdeTreeNode *selected;
  GObject *item = NULL;

  g_assert (GB_IS_PROJECT_TREE (self));

  if ((selected = ide_tree_get_selected (IDE_TREE (self))))
    {
      item = ide_tree_node_get_item (selected);
      if (item != NULL)
        g_object_ref (item);
    }

  ide_tree_rebuild (IDE_TREE (self));

  if (item != NULL)
    {
      selected = ide_tree_find_item (IDE_TREE (self), item);
      if (selected != NULL)
        {
          ide_tree_node_expand (selected, TRUE);
          ide_tree_node_select (selected);
          ide_tree_scroll_to_node (IDE_TREE (self), selected);
        }
      g_object_unref (item);
    }
}
void
gb_project_tree_reveal (GbProjectTree *self,
                        GFile         *file)
{
  g_autofree gchar *relpath = NULL;
  g_auto(GStrv) parts = NULL;
  IdeContext *context;
  IdeTreeNode *node;
  IdeVcs *vcs;
  GFile *workdir;
  guint i;

  g_return_if_fail (GB_IS_PROJECT_TREE (self));
  g_return_if_fail (G_IS_FILE (file));

  context = gb_project_tree_get_context (self);
  g_assert (IDE_IS_CONTEXT (context));

  if (context == NULL)
    return;

  vcs = ide_context_get_vcs (context);
  workdir = ide_vcs_get_working_directory (vcs);
  relpath = g_file_get_relative_path (workdir, file);

  if (relpath == NULL)
    return;

  node = ide_tree_find_child_node (IDE_TREE (self), NULL, find_files_node, NULL);
  if (node == NULL)
    return;

  parts = g_strsplit (relpath, G_DIR_SEPARATOR_S, 0);

  for (i = 0; parts [i]; i++)
    {
      node = ide_tree_find_child_node (IDE_TREE (self), node, find_child_node, parts [i]);
      if (node == NULL)
        return;
    }

  ide_tree_expand_to_node (IDE_TREE (self), node);
  ide_tree_scroll_to_node (IDE_TREE (self), node);
  ide_tree_node_select (node);
}