[gnome-builder] libide-projects: add similar file locator API
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide-projects: add similar file locator API
- Date: Tue, 12 Jul 2022 06:39:09 +0000 (UTC)
commit 062ad998286a03cf5fcbdd9dcd7a8a4549f15888
Author: Christian Hergert <chergert redhat com>
Date: Mon Jul 11 16:47:25 2022 -0700
libide-projects: add similar file locator API
src/libide/projects/ide-project.c | 3 +
src/libide/projects/ide-similar-file-locator.c | 89 ++++++++++++++++++++++++++
src/libide/projects/ide-similar-file-locator.h | 59 +++++++++++++++++
src/libide/projects/libide-projects.h | 1 +
src/libide/projects/meson.build | 5 +-
5 files changed, 155 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/projects/ide-project.c b/src/libide/projects/ide-project.c
index e3fb7cd78..2a1496ca7 100644
--- a/src/libide/projects/ide-project.c
+++ b/src/libide/projects/ide-project.c
@@ -23,11 +23,14 @@
#include "config.h"
#include <glib/gi18n.h>
+#include <libpeas/peas.h>
#include <libide-code.h>
+#include <libide-plugins.h>
#include "ide-buffer-private.h"
#include "ide-project.h"
+#include "ide-similar-file-locator.h"
struct _IdeProject
{
diff --git a/src/libide/projects/ide-similar-file-locator.c b/src/libide/projects/ide-similar-file-locator.c
new file mode 100644
index 000000000..35dca9969
--- /dev/null
+++ b/src/libide/projects/ide-similar-file-locator.c
@@ -0,0 +1,89 @@
+/* ide-similar-file-locator.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "ide-similar-file-locator"
+
+#include "config.h"
+
+#include "ide-similar-file-locator.h"
+
+G_DEFINE_INTERFACE (IdeSimilarFileLocator, ide_similar_file_locator, G_TYPE_OBJECT)
+
+static void
+ide_similar_file_locator_default_init (IdeSimilarFileLocatorInterface *iface)
+{
+}
+
+/**
+ * ide_similar_file_locator_list_async:
+ * @self: a #IdeSimilarFileLocator
+ * @file: a #GFile to find similar files for
+ * @cancellable: (nullable): a #GCancellable or %NULL
+ * @callback: callback to use to complete operation
+ * @user_data: closure data for @callback
+ *
+ * Asynchronously requests locating similar files.
+ *
+ * A similar file may be found such as those with similar file suffixes
+ * or perhaps a designer file associated with a source file.
+ */
+void
+ide_similar_file_locator_list_async (IdeSimilarFileLocator *self,
+ GFile *file,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ IDE_ENTRY;
+
+ g_return_if_fail (IDE_IS_SIMILAR_FILE_LOCATOR (self));
+ g_return_if_fail (G_IS_FILE (file));
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ IDE_SIMILAR_FILE_LOCATOR_GET_IFACE (self)->list_async (self, file, cancellable, callback, user_data);
+
+ IDE_EXIT;
+}
+
+/**
+ * ide_similar_file_locator_list_finish:
+ * @self: a #IdeSimilarFileLocator
+ * @result: a #GAsyncResult
+ * @error: location for a #GError, or %NULL
+ *
+ * Completes asynchronous request to list similar files.
+ *
+ * Returns: (transfer full): a #GListModel of #GFile or %NULL
+ */
+GListModel *
+ide_similar_file_locator_list_finish (IdeSimilarFileLocator *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ GListModel *ret;
+
+ IDE_ENTRY;
+
+ g_return_val_if_fail (IDE_IS_SIMILAR_FILE_LOCATOR (self), NULL);
+
+ ret = IDE_SIMILAR_FILE_LOCATOR_GET_IFACE (self)->list_finish (self, result, error);
+
+ IDE_RETURN (ret);
+}
diff --git a/src/libide/projects/ide-similar-file-locator.h b/src/libide/projects/ide-similar-file-locator.h
new file mode 100644
index 000000000..6b955b0fc
--- /dev/null
+++ b/src/libide/projects/ide-similar-file-locator.h
@@ -0,0 +1,59 @@
+/* ide-similar-file-locator.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#if !defined (IDE_PROJECTS_INSIDE) && !defined (IDE_PROJECTS_COMPILATION)
+# error "Only <libide-projects.h> can be included directly."
+#endif
+
+#include <libide-core.h>
+
+#define IDE_TYPE_SIMILAR_FILE_LOCATOR (ide_similar_file_locator_get_type())
+
+IDE_AVAILABLE_IN_ALL
+G_DECLARE_INTERFACE (IdeSimilarFileLocator, ide_similar_file_locator, IDE, SIMILAR_FILE_LOCATOR, GObject)
+
+struct _IdeSimilarFileLocatorInterface
+{
+ GTypeInterface parent_iface;
+
+ void (*list_async) (IdeSimilarFileLocator *self,
+ GFile *file,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ GListModel *(*list_finish) (IdeSimilarFileLocator *self,
+ GAsyncResult *result,
+ GError **error);
+};
+
+IDE_AVAILABLE_IN_ALL
+void ide_similar_file_locator_list_async (IdeSimilarFileLocator *self,
+ GFile *file,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+IDE_AVAILABLE_IN_ALL
+GListModel *ide_similar_file_locator_list_finish (IdeSimilarFileLocator *self,
+ GAsyncResult *result,
+ GError **error);
+
+G_END_DECLS
diff --git a/src/libide/projects/libide-projects.h b/src/libide/projects/libide-projects.h
index f1f7db00d..62e1cfc75 100644
--- a/src/libide/projects/libide-projects.h
+++ b/src/libide/projects/libide-projects.h
@@ -34,6 +34,7 @@
#include "ide-project-tree-addin.h"
#include "ide-projects-global.h"
#include "ide-recent-projects.h"
+#include "ide-similar-file-locator.h"
#include "ide-template-base.h"
#include "ide-template-provider.h"
diff --git a/src/libide/projects/meson.build b/src/libide/projects/meson.build
index 3cc9725c6..2106e9264 100644
--- a/src/libide/projects/meson.build
+++ b/src/libide/projects/meson.build
@@ -15,6 +15,7 @@ libide_projects_public_headers = [
'ide-project-template.h',
'ide-project-tree-addin.h',
'ide-recent-projects.h',
+ 'ide-similar-file-locator.h',
'ide-template-base.h',
'ide-template-provider.h',
'libide-projects.h',
@@ -43,6 +44,7 @@ libide_projects_public_sources = [
'ide-project-template.c',
'ide-project-tree-addin.c',
'ide-recent-projects.c',
+ 'ide-similar-file-locator.c',
'ide-template-base.c',
'ide-template-provider.c',
]
@@ -56,14 +58,13 @@ libide_projects_sources = libide_projects_public_sources + libide_projects_priva
libide_projects_deps = [
libgio_dep,
libgtk_dep,
- libdazzle_dep,
libtemplate_glib_dep,
libxml2_dep,
+ libide_code_dep,
libide_core_dep,
libide_io_dep,
libide_threading_dep,
- libide_code_dep,
libide_vcs_dep,
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]