Example #1
0
void
ide_application_discover_plugins (IdeApplication *self)
{
  PeasEngine *engine = peas_engine_get_default ();
  const GList *list;
  gchar *path;
  g_autoptr(GError) error = NULL;

  g_return_if_fail (IDE_IS_APPLICATION (self));

  if (g_getenv ("GB_IN_TREE_PLUGINS") != NULL)
    {
      GDir *dir;

      g_irepository_prepend_search_path (BUILDDIR"/src/gstyle");
      g_irepository_prepend_search_path (BUILDDIR"/src/libide");

      if ((dir = g_dir_open (BUILDDIR"/src/plugins", 0, NULL)))
        {
          const gchar *name;

          while ((name = g_dir_read_name (dir)))
            {
              path = g_build_filename (BUILDDIR, "src", "plugins", name, NULL);
              peas_engine_prepend_search_path (engine, path, path);
              g_free (path);
            }

          g_dir_close (dir);
        }
    }
  else
    {
      g_irepository_prepend_search_path (PACKAGE_LIBDIR"/gnome-builder/girepository-1.0");

      peas_engine_prepend_search_path (engine,
                                       PACKAGE_LIBDIR"/gnome-builder/plugins",
                                       PACKAGE_DATADIR"/gnome-builder/plugins");
    }

  /*
   * We have access to ~/.local/share/gnome-builder/ for plugins even when we are
   * bundled with flatpak, so might as well use it.
   */
  if (ide_is_flatpak ())
    {
      g_autofree gchar *plugins_dir = g_build_filename (g_get_home_dir (),
                                                        ".local",
                                                        "share",
                                                        "gnome-builder",
                                                        "plugins",
                                                        NULL);
      g_irepository_prepend_search_path (plugins_dir);
      peas_engine_prepend_search_path (engine, plugins_dir, plugins_dir);
    }

  if (!g_irepository_require (NULL, "Ide", "1.0", 0, &error) ||
      !g_irepository_require (NULL, "Gtk", "3.0", 0, &error) ||
      !g_irepository_require (NULL, "Dazzle", "1.0", 0, &error))
    g_warning ("Cannot enable Python 3 plugins: %s", error->message);
  else
    {
      /* Avoid spamming stderr with Ide import tracebacks */
      peas_engine_enable_loader (engine, "python3");
    }

  peas_engine_prepend_search_path (engine, "resource:///org/gnome/builder/plugins/", NULL);

  path = g_build_filename (g_get_user_data_dir (), "gnome-builder", "plugins", NULL);
  peas_engine_prepend_search_path (engine, path, NULL);
  g_free (path);

  list = peas_engine_get_plugin_list (engine);

  for (; list; list = list->next)
    {
      PeasPluginInfo *plugin_info = list->data;

      g_debug ("Discovered plugin \"%s\"",
               peas_plugin_info_get_module_name (plugin_info));
    }
}
Example #2
0
void
gb_plugins_init (void)
{
  PeasEngine *engine;
  const GList *list;

  /*
   * Ensure plugin-extensible types are registered.
   * This allows libgnome-builder.la to be linked and not drop
   * important symbols.
   */
  g_type_ensure (GB_TYPE_APPLICATION);
  g_type_ensure (GB_TYPE_DOCUMENT);
  g_type_ensure (GB_TYPE_TREE);
  g_type_ensure (GB_TYPE_TREE_BUILDER);
  g_type_ensure (GB_TYPE_TREE_NODE);
  g_type_ensure (GB_TYPE_VIEW);
  g_type_ensure (GB_TYPE_VIEW_GRID);
  g_type_ensure (GB_TYPE_WORKBENCH);
  g_type_ensure (GB_TYPE_WORKSPACE);

  engine = peas_engine_get_default ();

  peas_engine_enable_loader (engine, "python3");

  if (g_getenv ("GB_IN_TREE_PLUGINS") != NULL)
    {
      GDir *dir;

      g_irepository_require_private (g_irepository_get_default (),
                                     BUILDDIR"/libide",
                                     "Ide", "1.0", 0, NULL);

      if ((dir = g_dir_open (BUILDDIR"/plugins", 0, NULL)))
        {
          const gchar *name;

          while ((name = g_dir_read_name (dir)))
            {
              gchar *path;

              path = g_build_filename (BUILDDIR, "plugins", name, NULL);
              peas_engine_prepend_search_path (engine, path, path);
              g_free (path);
            }

          g_dir_close (dir);
        }
    }
  else
    {
      peas_engine_prepend_search_path (engine,
                                       PACKAGE_LIBDIR"/gnome-builder/plugins",
                                       PACKAGE_DATADIR"/gnome-builder/plugins");
    }

  list = peas_engine_get_plugin_list (engine);

  for (; list; list = list->next)
    {
      if (peas_plugin_info_is_builtin (list->data))
        peas_engine_load_plugin (engine, list->data);
    }
}