2022-11-20 17:16:51 -05:00
|
|
|
Allow Nautilus to search for extensions in the directories listed
|
|
|
|
in $NAUTILUS_EXTENSION_PATH.
|
|
|
|
|
2023-09-02 07:36:12 -04:00
|
|
|
Index: nautilus-44.2/src/nautilus-module.c
|
|
|
|
===================================================================
|
|
|
|
--- nautilus-44.2.orig/src/nautilus-module.c
|
|
|
|
+++ nautilus-44.2/src/nautilus-module.c
|
|
|
|
@@ -220,8 +220,16 @@ static void
|
2022-11-20 17:16:51 -05:00
|
|
|
load_module_dir (const char *dirname)
|
|
|
|
{
|
|
|
|
GDir *dir;
|
2023-09-02 07:36:12 -04:00
|
|
|
-
|
2022-11-20 17:16:51 -05:00
|
|
|
+ static GHashTable *loaded = NULL;
|
2023-09-02 07:36:12 -04:00
|
|
|
g_autoptr (GStrvBuilder) installed_module_name_builder = g_strv_builder_new ();
|
|
|
|
+
|
|
|
|
+ if (installed_module_names != NULL)
|
|
|
|
+ g_strv_builder_addv (installed_module_name_builder,
|
|
|
|
+ (const gchar **)installed_module_names);
|
2022-11-20 17:16:51 -05:00
|
|
|
+
|
|
|
|
+ if (loaded == NULL)
|
|
|
|
+ loaded = g_hash_table_new (g_str_hash, g_str_equal);
|
2023-09-02 07:36:12 -04:00
|
|
|
+
|
2022-11-20 17:16:51 -05:00
|
|
|
dir = g_dir_open (dirname, 0, NULL);
|
|
|
|
|
2023-09-02 07:36:12 -04:00
|
|
|
if (dir)
|
|
|
|
@@ -232,16 +240,24 @@ load_module_dir (const char *dirname)
|
2022-11-20 17:16:51 -05:00
|
|
|
{
|
|
|
|
if (g_str_has_suffix (name, "." G_MODULE_SUFFIX))
|
2023-09-02 07:36:12 -04:00
|
|
|
{
|
2022-11-20 17:16:51 -05:00
|
|
|
- char *filename;
|
|
|
|
-
|
|
|
|
- filename = g_build_filename (dirname,
|
|
|
|
- name,
|
|
|
|
- NULL);
|
2023-09-02 07:36:12 -04:00
|
|
|
- nautilus_module_load_file (filename, installed_module_name_builder);
|
2022-11-20 17:16:51 -05:00
|
|
|
- g_free (filename);
|
2023-09-02 07:36:12 -04:00
|
|
|
+ /* Make sure each module is loaded only twice or this could
|
|
|
|
+ lead to a crash. Double loading can occur if DIRNAME
|
|
|
|
+ occurs more than once in $NAUTILUS_EXTENSION_PATH. */
|
|
|
|
+ if (!g_hash_table_contains (loaded, name))
|
|
|
|
+ {
|
|
|
|
+ char *filename;
|
2022-11-20 17:16:51 -05:00
|
|
|
+
|
2023-09-02 07:36:12 -04:00
|
|
|
+ filename = g_build_filename (dirname,
|
|
|
|
+ name,
|
|
|
|
+ NULL);
|
|
|
|
+ nautilus_module_load_file (filename,
|
|
|
|
+ installed_module_name_builder);
|
|
|
|
+ g_hash_table_add (loaded, g_strdup (name));
|
|
|
|
+ g_free (filename);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
- }
|
2022-11-20 17:16:51 -05:00
|
|
|
|
2023-09-02 07:36:12 -04:00
|
|
|
+ }
|
2022-11-20 17:16:51 -05:00
|
|
|
g_dir_close (dir);
|
2023-09-02 07:36:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@@ -278,10 +294,24 @@ nautilus_module_setup (void)
|
2022-11-20 17:16:51 -05:00
|
|
|
|
|
|
|
if (!initialized)
|
|
|
|
{
|
|
|
|
+ const gchar *extension_path;
|
|
|
|
initialized = TRUE;
|
|
|
|
|
|
|
|
load_module_dir (NAUTILUS_EXTENSIONDIR);
|
|
|
|
|
|
|
|
+ /* Load additional modules from the user-provided search path. */
|
|
|
|
+ extension_path = g_getenv ("NAUTILUS_EXTENSION_PATH");
|
|
|
|
+ if (extension_path)
|
|
|
|
+ {
|
|
|
|
+ char **extension_dirs, **d;
|
|
|
|
+
|
|
|
|
+ extension_dirs = g_strsplit (extension_path, ":", -1);
|
|
|
|
+ for (d = extension_dirs; d != NULL && *d != NULL; d++)
|
|
|
|
+ load_module_dir (*d);
|
|
|
|
+
|
|
|
|
+ g_strfreev (extension_dirs);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
eel_debug_call_at_shutdown (free_module_objects);
|
|
|
|
}
|
|
|
|
}
|