unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 07170b12a4569bbcf542718a5aea4e580dc2643e 2643 bytes (raw)
name: gnu/packages/patches/nautilus-extension-search-path.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 
Allow Nautilus to search for extensions in the directories listed
in $NAUTILUS_EXTENSION_PATH.

Index: nautilus-43.2/src/nautilus-module.c
===================================================================
--- nautilus-43.2.orig/src/nautilus-module.c
+++ nautilus-43.2/src/nautilus-module.c
@@ -220,8 +220,13 @@ static void
 load_module_dir (const char *dirname)
 {
     GDir *dir;
+    static GHashTable *loaded = NULL;
+    g_autoptr (GStrvBuilder) installed_module_name_builder = NULL;
 
-    g_autoptr (GStrvBuilder) installed_module_name_builder = g_strv_builder_new ();
+    if (loaded == NULL)
+      loaded = g_hash_table_new (g_str_hash, g_str_equal);
+
+    installed_module_name_builder = g_strv_builder_new ();
     dir = g_dir_open (dirname, 0, NULL);
 
     if (dir)
@@ -232,13 +237,20 @@ load_module_dir (const char *dirname)
         {
             if (g_str_has_suffix (name, "." G_MODULE_SUFFIX))
             {
-                char *filename;
-
-                filename = g_build_filename (dirname,
-                                             name,
-                                             NULL);
-                nautilus_module_load_file (filename, installed_module_name_builder);
-                g_free (filename);
+              /* Make sure each module is loaded only twice or this could
+                 lead to a crash.  Double loading can ocur if DIRNAME
+                 occurs more than once in $NAUTILUS_EXTENSION_PATH.  */
+              if (!g_hash_table_contains (loaded, name))
+                {
+                  char *filename;
+
+                  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);
+                }
             }
         }
 
@@ -278,10 +290,24 @@ nautilus_module_setup (void)
 
     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);
     }
 }

debug log:

solving 07170b12a4 ...
found 07170b12a4 in https://git.savannah.gnu.org/cgit/guix.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).