After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 375349 - Allow use of environment variables in pluginrc, to enable GIMP to use a precomputed plugin config for portable drives
Allow use of environment variables in pluginrc, to enable GIMP to use a preco...
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
git master
Other All
: Normal enhancement
: 2.4
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2006-11-14 23:47 UTC by Jernej Simončič
Modified: 2006-11-18 16:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jernej Simončič 2006-11-14 23:47:21 UTC
This patch adds support for gimprc-like variables in paths used in pluginrc, making it possible to create a precomputed pluginrc, which doesn't have to be rewritten when GIMP is ran straight from portable media (eg. USB pendrives), speeding up the startup and reducing the wear on flash.

===================================================================
RCS file: /cvs/gnome/gimp/app/plug-in/plug-in-rc.c,v
retrieving revision 1.52
diff -u -r1.52 plug-in-rc.c
--- app/plug-in/plug-in-rc.c    5 Aug 2006 21:20:59 -0000       1.52
+++ app/plug-in/plug-in-rc.c    14 Nov 2006 23:37:11 -0000
@@ -233,13 +233,17 @@
   PlugInDef           *plug_in_def;
   GimpPlugInProcedure *proc = NULL;
   gchar               *name;
+  gchar               *path;
   GTokenType           token;

   if (! gimp_scanner_parse_string (scanner, &name))
     return G_TOKEN_STRING;

-  plug_in_def = plug_in_def_new (name);
-  g_free (name);
+  path = gimp_config_path_expand (name, FALSE, NULL);
+  g_free(name);
+
+  plug_in_def = plug_in_def_new (path);
+  g_free (path);

   if (! gimp_scanner_parse_int (scanner, (gint *) &plug_in_def->mtime))
     {
Comment 1 Sven Neumann 2006-11-15 15:50:51 UTC
Since we don't resubstitute paths when writing the pluginrc, I don't quite understand how the variables get into the file in the first place. The patch looks sane and it shouldn't slow down startup too badly, but still I fail to see what this is supposed to be good for.
Comment 2 Jernej Simončič 2006-11-15 20:23:10 UTC
On Windows, if you want to run the GIMP from a portable drive (typically a USB pendrive), you cannot know what drive letter the device will get when you plug it in another machine. My idea is to run the GIMP once, and let it create pluginrc, then do a simple search & replace in the file for X:\\Path\\to\\gimp\\lib\\2.0\\plug-ins -> ${gimp_plugin_dir}\\plug-ins. While this needs you to manually edit the file, it's still better than having the GIMP rewrite pluginrc (and having it re-run all plug-ins on startup, which can cause a significant slow down on portable media) when you insert the pendrive in another computer.
Comment 3 Michael Schumacher 2006-11-15 22:29:56 UTC
Other possible solutions would be to allow relative (to the pluginrc location? to pwd?) paths or absolute paths without a drive letter.
Comment 4 Sven Neumann 2006-11-15 22:47:18 UTC
I think the solution is fine. It's somewhat of a hack unless we also add code that does the opposite when writing pluginrc. But then all this expanding and unexpanding would in most cases be pointless. It would just burn CPU cycles and be a possible cause for problems. So perhaps we best stick with the simple patch that Jernej proposed.
Comment 5 Sven Neumann 2006-11-15 22:49:03 UTC
We could even generate a pluginrc at install time and install that during user installation. That would speed up the first start significantly. But I'm not sure if it's worth the effort.
Comment 6 Michael Natterer 2006-11-18 14:02:15 UTC
It seems we make wrong asumptions about the encoding of PlugInDef->prog
all the time. The was this string takes is about:

- gimp_plug_in_manager_add_from_file()  (filename encoding)
- plug_in_rc_write()                    (doesn't change encoding)

and upon re-reading pluginrc:

- plug_in_def_deserialize()             (asumes utf-8)
- gimp_config_path_expand()             (asumes utf-8 too)

So either I'm on crack or there is more that needs to be done
than simply applying this patch.

I suggest to convert the filename to utf-8 in plug_in_rc_write()
and to do the opposite in plug_in_def_deserialize() by passing
recode=TRUE to gimp_config_path_expand().

On the other hand all this seems to work just nice, so I might
be missing something.
Comment 7 Michael Natterer 2006-11-18 16:20:38 UTC
Fixed in CVS:

2006-11-18  Michael Natterer  <mitch@gimp.org>

	* app/plug-in/plug-in-rc.c (plug_in_def_deserialize): applied
	patch from Jernej Simoncic which enables environment variables and
	${gimp_foo} variables in plug-in filename and converts them to
	filesystem encoding. Fixes bug #375349.

	(plug_in_rc_write): write UTF-8 filenames to pluginrc.