[gnome-builder] gui: add ide_workspace_addin_find_by_module_name()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] gui: add ide_workspace_addin_find_by_module_name()
- Date: Mon, 26 Oct 2020 21:25:39 +0000 (UTC)
commit 76e58b1fefbdb0e044d5f9578c39737e0f534e44
Author: Christian Hergert <chergert redhat com>
Date: Mon Oct 26 14:12:29 2020 -0700
gui: add ide_workspace_addin_find_by_module_name()
This is useful for plugins to find coordinating components.
src/libide/gui/ide-workspace-addin.h | 17 ++++++++++-------
src/libide/gui/ide-workspace.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 7 deletions(-)
---
diff --git a/src/libide/gui/ide-workspace-addin.h b/src/libide/gui/ide-workspace-addin.h
index e03d39ecf..1bf8599bc 100644
--- a/src/libide/gui/ide-workspace-addin.h
+++ b/src/libide/gui/ide-workspace-addin.h
@@ -43,15 +43,18 @@ struct _IdeWorkspaceAddinInterface
};
IDE_AVAILABLE_IN_3_32
-void ide_workspace_addin_load (IdeWorkspaceAddin *self,
- IdeWorkspace *workspace);
+void ide_workspace_addin_load (IdeWorkspaceAddin *self,
+ IdeWorkspace *workspace);
IDE_AVAILABLE_IN_3_32
-void ide_workspace_addin_unload (IdeWorkspaceAddin *self,
- IdeWorkspace *workspace);
+void ide_workspace_addin_unload (IdeWorkspaceAddin *self,
+ IdeWorkspace *workspace);
IDE_AVAILABLE_IN_3_32
-void ide_workspace_addin_surface_set (IdeWorkspaceAddin *self,
- IdeSurface *surface);
+void ide_workspace_addin_surface_set (IdeWorkspaceAddin *self,
+ IdeSurface *surface);
IDE_AVAILABLE_IN_3_34
-gboolean ide_workspace_addin_can_close (IdeWorkspaceAddin *self);
+gboolean ide_workspace_addin_can_close (IdeWorkspaceAddin *self);
+IDE_AVAILABLE_IN_3_40
+IdeWorkspaceAddin *ide_workspace_addin_find_by_module_name (IdeWorkspace *workspace,
+ const gchar *module_name);
G_END_DECLS
diff --git a/src/libide/gui/ide-workspace.c b/src/libide/gui/ide-workspace.c
index 8140a87bc..c968e4899 100644
--- a/src/libide/gui/ide-workspace.c
+++ b/src/libide/gui/ide-workspace.c
@@ -992,3 +992,38 @@ _ide_workspace_move_front_page_mru (IdeWorkspace *self,
g_queue_unlink (&priv->page_mru, mru_link);
g_queue_push_head_link (&priv->page_mru, mru_link);
}
+
+/**
+ * ide_workspace_addin_find_by_module_name:
+ * @workspace: an #IdeWorkspace
+ * @module_name: the name of the addin module
+ *
+ * Finds the addin (if any) matching the plugin's @module_name.
+ *
+ * Returns: (transfer none) (nullable): an #IdeWorkspaceAddin or %NULL
+ *
+ * Since: 3.40
+ */
+IdeWorkspaceAddin *
+ide_workspace_addin_find_by_module_name (IdeWorkspace *workspace,
+ const gchar *module_name)
+{
+ IdeWorkspacePrivate *priv = ide_workspace_get_instance_private (workspace);
+ 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_WORKSPACE (workspace), NULL);
+ g_return_val_if_fail (module_name != NULL, NULL);
+
+ if (priv->addins == NULL)
+ return NULL;
+
+ engine = peas_engine_get_default ();
+
+ if ((plugin_info = peas_engine_get_plugin_info (engine, module_name)))
+ ret = ide_extension_set_adapter_get_extension (priv->addins, plugin_info);
+
+ return IDE_WORKSPACE_ADDIN (ret);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]