static void ide_build_system_get_build_flags_for_dir_cb (GObject *object, GAsyncResult *result, gpointer user_data) { GFile *dir = (GFile *)object; g_autoptr(IdeTask) task = user_data; g_autoptr(GError) error = NULL; g_autoptr(GPtrArray) infos = NULL; g_autoptr(GPtrArray) files = NULL; IdeBuildSystem *self; GCancellable *cancellable; IdeContext *context; IdeVcs *vcs; g_assert (G_IS_FILE (dir)); g_assert (G_IS_ASYNC_RESULT (result)); g_assert (IDE_IS_TASK (task)); infos = ide_g_file_get_children_finish (dir, result, &error); IDE_PTR_ARRAY_SET_FREE_FUNC (infos, g_object_unref); if (infos == NULL) { ide_task_return_error (task, g_steal_pointer (&error)); return; } self = ide_task_get_source_object (task); context = ide_object_get_context (IDE_OBJECT (self)); vcs = ide_vcs_from_context (context); cancellable = ide_task_get_cancellable (task); files = g_ptr_array_new_with_free_func (g_object_unref); for (guint i = 0; i < infos->len; i++) { GFileInfo *file_info = g_ptr_array_index (infos, i); GFileType file_type = g_file_info_get_file_type (file_info); if (file_type == G_FILE_TYPE_REGULAR) { const gchar *name = g_file_info_get_name (file_info); g_autoptr(GFile) child = g_file_get_child (dir, name); if (!ide_vcs_is_ignored (vcs, child, NULL)) g_ptr_array_add (files, g_steal_pointer (&child)); } } ide_build_system_get_build_flags_for_files_async (self, files, cancellable, ide_build_system_get_build_flags_for_dir_cb2, g_steal_pointer (&task)); }
static void build_file (GbProjectTreeBuilder *self, IdeTreeNode *node) { g_autoptr(GFileEnumerator) enumerator = NULL; GbProjectFile *project_file; gpointer file_info_ptr; IdeVcs *vcs; GFile *file; IdeTree *tree; gint count = 0; gboolean show_ignored_files; g_return_if_fail (GB_IS_PROJECT_TREE_BUILDER (self)); g_return_if_fail (IDE_IS_TREE_NODE (node)); project_file = GB_PROJECT_FILE (ide_tree_node_get_item (node)); tree = ide_tree_builder_get_tree (IDE_TREE_BUILDER (self)); show_ignored_files = gb_project_tree_get_show_ignored_files (GB_PROJECT_TREE (tree)); vcs = get_vcs (node); /* * TODO: Make this all async. */ if (!gb_project_file_get_is_directory (project_file)) return; file = gb_project_file_get_file (project_file); enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME"," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME"," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (enumerator == NULL) return; while ((file_info_ptr = g_file_enumerator_next_file (enumerator, NULL, NULL))) { g_autoptr(GFileInfo) item_file_info = file_info_ptr; g_autoptr(GFile) item_file = NULL; g_autoptr(GbProjectFile) item = NULL; IdeTreeNode *child; const gchar *name; const gchar *display_name; const gchar *icon_name; gboolean ignored; name = g_file_info_get_name (item_file_info); item_file = g_file_get_child (file, name); ignored = ide_vcs_is_ignored (vcs, item_file, NULL); if (ignored && !show_ignored_files) continue; item = gb_project_file_new (item_file, item_file_info); display_name = gb_project_file_get_display_name (item); icon_name = gb_project_file_get_icon_name (item); child = g_object_new (IDE_TYPE_TREE_NODE, "icon-name", icon_name, "text", display_name, "item", item, "use-dim-label", ignored, NULL); ide_tree_node_insert_sorted (node, child, compare_nodes_func, self); if (g_file_info_get_file_type (item_file_info) == G_FILE_TYPE_DIRECTORY) ide_tree_node_set_children_possible (child, TRUE); count++; } /* * If we didn't add any children to this node, insert an empty node to * notify the user that nothing was found. */ if (count == 0) { IdeTreeNode *child; child = g_object_new (IDE_TYPE_TREE_NODE, "icon-name", NULL, "text", _("Empty"), "use-dim-label", TRUE, NULL); ide_tree_node_append (node, child); } }