1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-07-07 09:29:30 +00:00

plugins: Rescan for plugins after adding search paths

Using rescan allows use to give a priority to search paths. So this way
plugins in `CALLS_PLUGIN_DIR` take precedence over plugins we ship.

This also makes sure that the plugin test searches in the same location
as CallsManager.
This commit is contained in:
Julian Sparber 2022-10-26 15:09:11 +02:00 committed by Evangelos Ribeiro Tzaras
parent c821b03efc
commit 1d873a4b05
2 changed files with 23 additions and 4 deletions

View file

@ -803,18 +803,17 @@ calls_manager_init (CallsManager *self)
dir = g_getenv ("CALLS_PLUGIN_DIR");
if (dir && dir[0] != '\0') {
g_autofree char *plugin_dir_provider = NULL;
/** Add the directory to the search path. prepend_search_path() does not work
* as expected. see https://gitlab.gnome.org/GNOME/libpeas/-/issues/19
*/
plugin_dir_provider = g_build_filename (dir, "provider", NULL);
g_debug ("Adding %s to plugin search path", plugin_dir_provider);
peas_engine_add_search_path (peas, plugin_dir_provider, NULL);
peas_engine_prepend_search_path (peas, plugin_dir_provider, NULL);
}
default_plugin_dir_provider = g_build_filename(PLUGIN_LIBDIR, "provider", NULL);
peas_engine_add_search_path (peas, default_plugin_dir_provider, NULL);
g_debug ("Scanning for plugins in `%s'", default_plugin_dir_provider);
peas_engine_rescan_plugins (peas);
}

View file

@ -6,6 +6,8 @@
* Author: Evangelos Ribeiro Tzaras <evangelos.tzaras@puri.sm>
*/
#include "config.h"
#include "calls-provider.h"
#include <gtk/gtk.h>
@ -47,15 +49,33 @@ main (gint argc,
gchar *argv[])
{
g_autofree char *plugin_dir_provider = NULL;
PeasEngine *peas;
const gchar *dir;
g_autofree char *default_plugin_dir_provider = NULL;
gtk_test_init (&argc, &argv, NULL);
peas = peas_engine_get_default ();
/* Add builddir as search path */
#ifdef PLUGIN_BUILDDIR
plugin_dir_provider = g_build_filename (PLUGIN_BUILDDIR, "provider", NULL);
peas_engine_add_search_path (peas_engine_get_default (), plugin_dir_provider, NULL);
#endif
dir = g_getenv ("CALLS_PLUGIN_DIR");
if (dir && dir[0] != '\0') {
g_autofree char *plugin_dir_provider = NULL;
plugin_dir_provider = g_build_filename (dir, "provider", NULL);
g_debug ("Adding %s to plugin search path", plugin_dir_provider);
peas_engine_prepend_search_path (peas, plugin_dir_provider, NULL);
}
default_plugin_dir_provider = g_build_filename (PLUGIN_LIBDIR, "provider", NULL);
g_debug ("Adding %s to plugin search path", default_plugin_dir_provider);
peas_engine_add_search_path (peas, default_plugin_dir_provider, NULL);
peas_engine_rescan_plugins (peas);
g_test_add_func("/Calls/Plugins/load_plugins", test_calls_plugin_loading);
return g_test_run();