GNOME Bugzilla – Bug 375349
Allow use of environment variables in pluginrc, to enable GIMP to use a precomputed plugin config for portable drives
Last modified: 2006-11-18 16:20:38 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)) {
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.
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.
Other possible solutions would be to allow relative (to the pluginrc location? to pwd?) paths or absolute paths without a drive letter.
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.
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.
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.
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.