[gnome-builder] gui: add ide_application_find_addin_by_module_name()



commit 2071dfd7c66a55e1b8a66ca47cab619b35663973
Author: Christian Hergert <chergert redhat com>
Date:   Thu Aug 8 13:06:51 2019 -0700

    gui: add ide_application_find_addin_by_module_name()
    
    Locates an IdeApplicationAddin based on the module name.

 src/libide/gui/ide-application.c | 38 ++++++++++++++++++++++++++++++++++++++
 src/libide/gui/ide-application.h |  3 +++
 2 files changed, 41 insertions(+)
---
diff --git a/src/libide/gui/ide-application.c b/src/libide/gui/ide-application.c
index 7b6ac91c5..ce3d466b6 100644
--- a/src/libide/gui/ide-application.c
+++ b/src/libide/gui/ide-application.c
@@ -778,3 +778,41 @@ ide_application_get_command_line_handled (IdeApplication          *self,
 
   return !!g_object_get_data (G_OBJECT (cmdline), "COMMAND_LINE_HANDLED");
 }
+
+/**
+ * ide_application_find_addin_by_module_name:
+ * @self: a #IdeApplication
+ * @module_name: the name of the plugin module
+ *
+ * Finds a loaded #IdeApplicationAddin within @self that was part of
+ * the plugin matching @module_name.
+ *
+ * Returns: (transfer none) (type IdeApplicationAddin) (nullable): an
+ *   #IdeApplicationAddin or %NULL.
+ *
+ * Since: 3.34
+ */
+gpointer
+ide_application_find_addin_by_module_name (IdeApplication *self,
+                                           const gchar    *module_name)
+{
+  PeasEngine *engine;
+  PeasPluginInfo *plugin_info;
+
+  if (self == NULL)
+    self = IDE_APPLICATION_DEFAULT;
+
+  g_return_val_if_fail (IDE_IS_APPLICATION (self), NULL);
+  g_return_val_if_fail (module_name != NULL, NULL);
+
+  if (self->addins == NULL)
+    return NULL;
+
+  engine = peas_engine_get_default ();
+  plugin_info = peas_engine_get_plugin_info (engine, module_name);
+
+  if (plugin_info == NULL)
+    return NULL;
+
+  return peas_extension_set_get_extension (self->addins, plugin_info);
+}
diff --git a/src/libide/gui/ide-application.h b/src/libide/gui/ide-application.h
index dd8cc3dbf..8dca6709e 100644
--- a/src/libide/gui/ide-application.h
+++ b/src/libide/gui/ide-application.h
@@ -89,5 +89,8 @@ GDBusProxy    *ide_application_get_worker_finish        (IdeApplication
 IDE_AVAILABLE_IN_3_32
 IdeWorkbench  *ide_application_find_workbench_for_file  (IdeApplication           *self,
                                                          GFile                    *file);
+IDE_AVAILABLE_IN_3_34
+gpointer       ide_application_find_addin_by_module_name (IdeApplication           *self,
+                                                          const gchar              *module_name);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]