[gnome-builder] core: add helper to get IdeContextAddin by module-name
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] core: add helper to get IdeContextAddin by module-name
- Date: Wed, 3 Mar 2021 22:54:30 +0000 (UTC)
commit bc45a7097f6bbdbd403cc9f527b21e4cfcccb8ef
Author: Christian Hergert <chergert redhat com>
Date: Wed Mar 3 14:49:01 2021 -0800
core: add helper to get IdeContextAddin by module-name
src/libide/core/ide-context-addin.h | 31 +++++++++++++++++--------------
src/libide/core/ide-context.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 14 deletions(-)
---
diff --git a/src/libide/core/ide-context-addin.h b/src/libide/core/ide-context-addin.h
index ea4e3b575..74ebab184 100644
--- a/src/libide/core/ide-context-addin.h
+++ b/src/libide/core/ide-context-addin.h
@@ -50,24 +50,27 @@ struct _IdeContextAddinInterface
IdeContext *context);
};
+IDE_AVAILABLE_IN_3_40
+IdeContextAddin *ide_context_addin_find_by_module_name (IdeContext *context,
+ const gchar *module_name);
IDE_AVAILABLE_IN_3_32
-void ide_context_addin_load_project_async (IdeContextAddin *self,
- IdeContext *context,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
+void ide_context_addin_load_project_async (IdeContextAddin *self,
+ IdeContext *context,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
IDE_AVAILABLE_IN_3_32
-gboolean ide_context_addin_load_project_finish (IdeContextAddin *self,
- GAsyncResult *result,
- GError **error);
+gboolean ide_context_addin_load_project_finish (IdeContextAddin *self,
+ GAsyncResult *result,
+ GError **error);
IDE_AVAILABLE_IN_3_32
-void ide_context_addin_load (IdeContextAddin *self,
- IdeContext *context);
+void ide_context_addin_load (IdeContextAddin *self,
+ IdeContext *context);
IDE_AVAILABLE_IN_3_32
-void ide_context_addin_unload (IdeContextAddin *self,
- IdeContext *context);
+void ide_context_addin_unload (IdeContextAddin *self,
+ IdeContext *context);
IDE_AVAILABLE_IN_3_32
-void ide_context_addin_project_loaded (IdeContextAddin *self,
- IdeContext *context);
+void ide_context_addin_project_loaded (IdeContextAddin *self,
+ IdeContext *context);
G_END_DECLS
diff --git a/src/libide/core/ide-context.c b/src/libide/core/ide-context.c
index 108d46f61..ffb3fe0fd 100644
--- a/src/libide/core/ide-context.c
+++ b/src/libide/core/ide-context.c
@@ -863,3 +863,37 @@ _ide_context_set_has_project (IdeContext *self)
self->project_loaded = TRUE;
ide_object_unlock (IDE_OBJECT (self));
}
+
+/**
+ * ide_context_addin_find_by_module_name:
+ * @context: an #IdeContext
+ * @module_name: the name of the addin module
+ *
+ * Finds the addin (if any) matching the plugin's @module_name.
+ *
+ * Returns: (transfer none) (nullable): an #IdeContextAddin or %NULL
+ *
+ * Since: 3.40
+ */
+IdeContextAddin *
+ide_context_addin_find_by_module_name (IdeContext *context,
+ const gchar *module_name)
+{
+ PeasPluginInfo *plugin_info;
+ PeasExtension *ret = NULL;
+ PeasEngine *engine;
+
+ g_return_val_if_fail (IDE_IS_MAIN_THREAD (), NULL);
+ g_return_val_if_fail (IDE_IS_CONTEXT (context), NULL);
+ g_return_val_if_fail (module_name != NULL, NULL);
+
+ if (context->addins == NULL)
+ return NULL;
+
+ engine = peas_engine_get_default ();
+
+ if ((plugin_info = peas_engine_get_plugin_info (engine, module_name)))
+ ret = peas_extension_set_get_extension (context->addins, plugin_info);
+
+ return IDE_CONTEXT_ADDIN (ret);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]