unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
blob fcf55ba14f4826b50e98c93c436ac4bc2eb0c3d3 8339 bytes (raw)
name: gnu/packages/patches/thunar-search-paths.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
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
 
From 848f1dfb2d2f404efa5371817285236d33b32a5c Mon Sep 17 00:00:00 2001
From: tumashu <tumashu@163.com>
Date: Tue, 22 Mar 2022 20:16:19 +0000
Subject: [PATCH] Look for thunar plugins at $THUNARX_DIRS (Issue #748)

THUNARX_DIRS is a list of directories where thunar plugins are looked
for. It is needed for distributions like NixOS/GuixOS that do not
install all plugins in the same directory. In NixOS/GuixOS each
package is installed in a self contained directory.

MR !197
---
 thunarx/thunarx-provider-factory.c | 86 +++++++++++++++++-------------
 thunarx/thunarx-provider-module.c  | 68 ++++++++++++++---------
 2 files changed, 91 insertions(+), 63 deletions(-)

diff --git a/thunarx/thunarx-provider-factory.c b/thunarx/thunarx-provider-factory.c
index 94b11545..386c3417 100644
--- a/thunarx/thunarx-provider-factory.c
+++ b/thunarx/thunarx-provider-factory.c
@@ -154,54 +154,66 @@ thunarx_provider_factory_load_modules (ThunarxProviderFactory *factory)
   GList                 *modules = NULL;
   GList                 *lp;
   GDir                  *dp;
+  gchar                 *dirs_string;
+  gchar                **dirs;
 
-  dp = g_dir_open (THUNARX_DIRECTORY, 0, NULL);
-  if (G_LIKELY (dp != NULL))
+  dirs_string = (gchar *) g_getenv ("THUNARX_DIRS");
+  if (!dirs_string)
+    dirs_string = THUNARX_DIRECTORY;
+  dirs = g_strsplit (dirs_string, G_SEARCHPATH_SEPARATOR_S, 0);
+
+  for (int i = 0; dirs[i] != NULL; i++)
     {
-      /* determine the types for all existing plugins */
-      for (;;)
-        {
-          /* read the next entry from the directory */
-          name = g_dir_read_name (dp);
-          if (G_UNLIKELY (name == NULL))
-            break;
 
-          /* check if this is a valid plugin file */
-          if (g_str_has_suffix (name, "." G_MODULE_SUFFIX))
-            {
-              /* check if we already have that module */
-              for (lp = thunarx_provider_modules; lp != NULL; lp = lp->next)
-                if (g_str_equal (G_TYPE_MODULE (lp->data)->name, name))
-                  break;
+      dp = g_dir_open (dirs[i], 0, NULL);
 
-              /* use or allocate a new module for the file */
-              if (G_UNLIKELY (lp != NULL))
-                {
-                  /* just use the existing module */
-                  module = THUNARX_PROVIDER_MODULE (lp->data);
-                }
-              else
-                {
-                  /* allocate the new module and add it to our list */
-                  module = thunarx_provider_module_new (name);
-                  thunarx_provider_modules = g_list_prepend (thunarx_provider_modules, module);
-                }
+      if (G_LIKELY (dp != NULL))
+        {
+          /* determine the types for all existing plugins */
+          for (;;)
+            {
+              /* read the next entry from the directory */
+              name = g_dir_read_name (dp);
+              if (G_UNLIKELY (name == NULL))
+                break;
 
-              /* try to load the module */
-              if (g_type_module_use (G_TYPE_MODULE (module)))
+              /* check if this is a valid plugin file */
+              if (g_str_has_suffix (name, "." G_MODULE_SUFFIX))
                 {
-                  /* add the types provided by the module */
-                  thunarx_provider_factory_add (factory, module);
-
-                  /* add the module to our list */
-                  modules = g_list_prepend (modules, module);
+                  /* check if we already have that module */
+                  for (lp = thunarx_provider_modules; lp != NULL; lp = lp->next)
+                    if (g_str_equal (G_TYPE_MODULE (lp->data)->name, name))
+                      break;
+
+                  /* use or allocate a new module for the file */
+                  if (G_UNLIKELY (lp != NULL))
+                    {
+                      continue;
+                    }
+                  else
+                    {
+                      /* allocate the new module and add it to our list */
+                      module = thunarx_provider_module_new (name);
+                      thunarx_provider_modules = g_list_prepend (thunarx_provider_modules, module);
+                    }
+
+                  /* try to load the module */
+                  if (g_type_module_use (G_TYPE_MODULE (module)))
+                    {
+                      /* add the types provided by the module */
+                      thunarx_provider_factory_add (factory, module);
+
+                      /* add the module to our list */
+                      modules = g_list_prepend (modules, module);
+                    }
                 }
             }
-        }
 
-      g_dir_close (dp);
+          g_dir_close (dp);
+        }
     }
 
+  g_strfreev (dirs);
   return modules;
 }
 
diff --git a/thunarx/thunarx-provider-module.c b/thunarx/thunarx-provider-module.c
index 023ad2ae..5ddf38b2 100644
--- a/thunarx/thunarx-provider-module.c
+++ b/thunarx/thunarx-provider-module.c
@@ -175,37 +175,53 @@ thunarx_provider_module_load (GTypeModule *type_module)
 {
   ThunarxProviderModule *module = THUNARX_PROVIDER_MODULE (type_module);
   gchar                 *path;
+  gchar                 *dirs_string;
+  gchar                **dirs;
+  gboolean               found;
 
-  /* load the module using the runtime link editor */
-  path = g_build_filename (THUNARX_DIRECTORY, type_module->name, NULL);
-  module->library = g_module_open (path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
-  g_free (path);
+  dirs_string = (gchar *) g_getenv ("THUNARX_DIRS");
+  if (!dirs_string)
+    dirs_string = THUNARX_DIRECTORY;
+  dirs = g_strsplit (dirs_string, G_SEARCHPATH_SEPARATOR_S, 0);
 
-  /* check if the load operation was successfull */
-  if (G_UNLIKELY (module->library == NULL))
-    {
-      g_printerr ("Thunar :Failed to load plugin `%s': %s\n", type_module->name, g_module_error ());
-      return FALSE;
-    }
+  found = FALSE;
 
-  /* verify that all required public symbols are present in the plugin's symbol table */
-  if (!g_module_symbol (module->library, "thunar_extension_shutdown", (gpointer) &module->shutdown)
-      || !g_module_symbol (module->library, "thunar_extension_initialize", (gpointer) &module->initialize)
-      || !g_module_symbol (module->library, "thunar_extension_list_types", (gpointer) &module->list_types))
+  for (int i = 0; !found && dirs[i] != NULL; i++)
     {
-      g_printerr ("Thunar :Plugin `%s' lacks required symbols.\n", type_module->name);
-      g_module_close (module->library);
-      return FALSE;
+      /* load the module using the runtime link editor */
+      path = g_build_filename (dirs[i], type_module->name, NULL);
+
+      module->library = g_module_open (path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+      g_free (path);
+
+      /* check if the load operation was successfull */
+      if (G_UNLIKELY (module->library == NULL))
+        {
+          g_printerr ("Thunar :Failed to load plugin `%s' from `%s': %s\n", type_module->name, path, g_module_error ());
+          continue;
+        }
+
+      /* verify that all required public symbols are present in the plugin's symbol table */
+      if (!g_module_symbol (module->library, "thunar_extension_shutdown", (gpointer) &module->shutdown)
+          || !g_module_symbol (module->library, "thunar_extension_initialize", (gpointer) &module->initialize)
+          || !g_module_symbol (module->library, "thunar_extension_list_types", (gpointer) &module->list_types))
+        {
+          g_printerr ("Thunar :Plugin `%s' in `%s' lacks required symbols.\n", type_module->name, path);
+          g_module_close (module->library);
+          continue;
+        }
+
+      /* initialize the plugin */
+      (*module->initialize) (module);
+
+      /* ensure that the module will never be unloaded if it requests to be kept in memory */
+      if (G_UNLIKELY (module->resident))
+        g_module_make_resident (module->library);
+
+      found = TRUE;
     }
-
-  /* initialize the plugin */
-  (*module->initialize) (module);
-
-  /* ensure that the module will never be unloaded if it requests to be kept in memory */
-  if (G_UNLIKELY (module->resident))
-    g_module_make_resident (module->library);
-
-  return TRUE;
+  g_strfreev (dirs);
+  return found;
 }
 
 
-- 
2.34.0


debug log:

solving fcf55ba14f ...
found fcf55ba14f in https://yhetil.org/guix-bugs/20220322204942.9624-5-tumashu@163.com/

applying [1/1] https://yhetil.org/guix-bugs/20220322204942.9624-5-tumashu@163.com/
diff --git a/gnu/packages/patches/thunar-search-paths.patch b/gnu/packages/patches/thunar-search-paths.patch
new file mode 100644
index 0000000000..fcf55ba14f

1:33: trailing whitespace.
 
1:50: trailing whitespace.
 
1:59: trailing whitespace.
 
1:81: trailing whitespace.
 
1:121: trailing whitespace.
 
Checking patch gnu/packages/patches/thunar-search-paths.patch...
Applied patch gnu/packages/patches/thunar-search-paths.patch cleanly.
warning: squelched 9 whitespace errors
warning: 14 lines add whitespace errors.

index at:
100644 fcf55ba14f4826b50e98c93c436ac4bc2eb0c3d3	gnu/packages/patches/thunar-search-paths.patch

(*) 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).