Пример #1
0
static void
test_extension_seed_plugin_info (PeasEngine *engine)
{
  PeasPluginInfo *info;
  PeasExtension *extension;
  PeasExtensionSeed *sexten;
  SeedValue seed_value;
  GValue gvalue = { 0 };

  info = peas_engine_get_plugin_info (engine, "extension-seed");

  g_assert (peas_engine_load_plugin (engine, info));

  extension = peas_engine_create_extension (engine, info,
                                            INTROSPECTION_TYPE_CALLABLE,
                                            NULL);

  g_assert (PEAS_IS_EXTENSION (extension));

  sexten = (PeasExtensionSeed *) extension;
  seed_value = seed_object_get_property (sexten->js_context, sexten->js_object,
                                         "plugin_info");

  g_assert (seed_value_to_gvalue (sexten->js_context, seed_value,
                                  PEAS_TYPE_PLUGIN_INFO, &gvalue,
                                  NULL));

  g_assert (g_value_get_boxed (&gvalue) == info);

  g_value_unset (&gvalue);

  g_object_unref (extension);
}
Пример #2
0
static void
test_extension_gjs_plugin_info (PeasEngine *engine)
{
    PeasPluginInfo *info;
    PeasExtension *extension;
    PeasExtensionGjs *gexten;
    jsval js_value;
    GValue gvalue = { 0 };

    info = peas_engine_get_plugin_info (engine, "extension-gjs");

    g_assert (peas_engine_load_plugin (engine, info));

    extension = peas_engine_create_extension (engine, info,
                INTROSPECTION_TYPE_CALLABLE,
                NULL);

    g_assert (PEAS_IS_EXTENSION (extension));

    gexten = (PeasExtensionGjs *) extension;

    g_value_init (&gvalue, PEAS_TYPE_PLUGIN_INFO);

    g_assert (JS_GetProperty (gexten->js_context, gexten->js_object,
                              "plugin_info", &js_value));
    g_assert (gjs_value_to_g_value (gexten->js_context, js_value, &gvalue));

    g_assert (g_value_get_boxed (&gvalue) == info);

    g_value_unset (&gvalue);

    g_object_unref (extension);
}
Пример #3
0
static void
test_extension_gjs_nonexistent (PeasEngine *engine)
{
  PeasPluginInfo *info;

  testing_util_push_log_hook ("*Failed to open *extension-gjs-nonexistent.js*");
  testing_util_push_log_hook ("Error loading plugin 'extension-gjs-nonexistent'");

  info = peas_engine_get_plugin_info (engine, "extension-gjs-nonexistent");

  g_assert (!peas_engine_load_plugin (engine, info));
}
Пример #4
0
/**
 * ide_editor_addin_find_by_module_name:
 * @editor: an #IdeEditorPerspective
 * @module_name: the module name of the addin
 *
 * This function allows locating an #IdeEditorAddin that is attached
 * to the #IdeEditorPerspective by the addin module name. The module name
 * should match the value specified in the ".plugin" module definition.
 *
 * Returns: (transfer none) (nullable): An #IdeEditorAddin or %NULL
 */
IdeEditorAddin *
ide_editor_addin_find_by_module_name (IdeEditorPerspective *editor,
                                      const gchar          *module_name)
{
  PeasExtension *ret = NULL;
  PeasPluginInfo *plugin_info;

  g_return_val_if_fail (IDE_IS_EDITOR_PERSPECTIVE (editor), NULL);
  g_return_val_if_fail (module_name != NULL, NULL);

  plugin_info = peas_engine_get_plugin_info (peas_engine_get_default (), module_name);

  if (plugin_info != NULL)
    ret = peas_extension_set_get_extension (editor->addins, plugin_info);
  else
    g_warning ("No such module found \"%s\"", module_name);

  return ret ? IDE_EDITOR_ADDIN (ret) : NULL;
}
Пример #5
0
/**
 * ide_frame_addin_find_by_module_name:
 * @frame: An #IdeFrame
 * @module_name: the module name which provides the addin
 *
 * This function will locate the #IdeFrameAddin that was registered by
 * the plugin named @module_name (which should match the "Module" field
 * provided in the .plugin file).
 *
 * If no module was found or that module does not implement the
 * #IdeFrameAddinInterface, then %NULL is returned.
 *
 * Returns: (transfer none) (nullable): An #IdeFrameAddin or %NULL
 *
 * Since: 3.32
 */
IdeFrameAddin *
ide_frame_addin_find_by_module_name (IdeFrame    *frame,
                                     const gchar *module_name)
{
  IdeFramePrivate *priv = ide_frame_get_instance_private (frame);
  PeasExtension *ret = NULL;
  PeasPluginInfo *plugin_info;

  g_return_val_if_fail (IDE_IS_FRAME (frame), NULL);
  g_return_val_if_fail (priv->addins != NULL, NULL);
  g_return_val_if_fail (module_name != NULL, NULL);

  plugin_info = peas_engine_get_plugin_info (peas_engine_get_default (), module_name);

  if (plugin_info != NULL)
    ret = peas_extension_set_get_extension (priv->addins, plugin_info);
  else
    g_warning ("No addin could be found matching module \"%s\"", module_name);

  return ret ? IDE_FRAME_ADDIN (ret) : NULL;
}
Пример #6
0
static void
test_gtk_plugin_manager_view_enable_builtin_plugin (TestFixture *fixture)
{
  GtkTreeIter iter;
  GtkTreePath *path;
  GtkTreeViewColumn *column;
  PeasPluginInfo *info;

  peas_gtk_plugin_manager_view_set_show_builtin (fixture->view, TRUE);

  info = peas_engine_get_plugin_info (fixture->engine, "builtin");

  testing_get_iter_for_plugin_info (fixture->view, info, &iter);

  path = gtk_tree_model_get_path (fixture->model, &iter);
  column = gtk_tree_view_get_column (fixture->tree_view, 0);

  g_assert (!peas_plugin_info_is_loaded (info));
  gtk_tree_view_row_activated (fixture->tree_view, path, column);
  g_assert (!peas_plugin_info_is_loaded (info));

  gtk_tree_path_free (path);
}
Пример #7
0
static void
liferea_plugins_engine_init (LifereaPluginsEngine * engine)
{
  gchar *typelib_dir;
  GError *error = NULL;
  PeasPluginInfo *plugin_installer_plugin_info = NULL;

  engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
                                              LIFEREA_TYPE_PLUGINS_ENGINE,
                                              LifereaPluginsEnginePrivate);

  peas_engine_enable_loader (PEAS_ENGINE (engine), "python3");

  engine->priv->plugin_settings = g_settings_new ("net.sf.liferea.plugins");

  /* Require Lifereas's typelib. */
  typelib_dir = g_build_filename (PACKAGE_LIB_DIR,
                                  "girepository-1.0", NULL);

  if (!g_irepository_require_private (g_irepository_get_default (),
	  typelib_dir, "Liferea", "3.0", 0, &error))
    {
      g_warning ("Could not load Liferea repository: %s", error->message);
      g_error_free (error);
      error = NULL;
    }

  g_free (typelib_dir);

  /* This should be moved to libpeas */
  if (!g_irepository_require (g_irepository_get_default (),
                              "Peas", "1.0", 0, &error))
    {
      g_warning ("Could not load Peas repository: %s", error->message);
      g_error_free (error);
      error = NULL;
    }

  if (!g_irepository_require (g_irepository_get_default (),
                              "PeasGtk", "1.0", 0, &error))
    {
      g_warning ("Could not load PeasGtk repository: %s", error->message);
      g_error_free (error);
      error = NULL;
    }

  peas_engine_add_search_path (PEAS_ENGINE (engine),
                               g_build_filename (g_get_user_data_dir (), "liferea", "plugins", NULL),
                               g_build_filename (g_get_user_data_dir (), "liferea", "plugins", NULL));

  peas_engine_add_search_path (PEAS_ENGINE (engine),
                               g_build_filename (PACKAGE_LIB_DIR,  "plugins", NULL),
                               g_build_filename (PACKAGE_DATA_DIR, "plugins", NULL));

  g_settings_bind (engine->priv->plugin_settings,
                   "active-plugins",
                   engine, "loaded-plugins", G_SETTINGS_BIND_DEFAULT);

  plugin_installer_plugin_info = peas_engine_get_plugin_info (PEAS_ENGINE (engine), "plugin-installer");
  if (plugin_installer_plugin_info)
	peas_engine_load_plugin (PEAS_ENGINE (engine), plugin_installer_plugin_info);
  else
	g_warning ("The plugin-installer plugin was not found.");
}