Commit 3d5a8450 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added a function that returns all file extensions registered in the

2007-04-18  Sven Neumann  <sven@gimp.org>

	* app/plug-in/gimpinterpreterdb.[ch]: added a function that
	returns all file extensions registered in the interpreter db.

	* app/plug-in/gimppluginmanager.c (gimp_plug_in_manager_restore):
	if the PATHEXT environment variable is set, append all registered
	file extensions to it. This way GIMP can recognize Python scripts
	as plug-ins on platforms where the executable bit is unknown.


svn path=/trunk/; revision=22282
parent 9b1a0fee
2007-04-18 Sven Neumann <sven@gimp.org>
* app/plug-in/gimpinterpreterdb.[ch]: added a function that
returns all file extensions registered in the interpreter db.
* app/plug-in/gimppluginmanager.c (gimp_plug_in_manager_restore):
if the PATHEXT environment variable is set, append all registered
file extensions to it. This way GIMP can recognize Python scripts
as plug-ins on platforms where the executable bit is unknown.
2007-04-18 Sven Neumann <sven@gimp.org>
* data/tips/gimp-tips.xml.in: fixed a typo.
......@@ -718,6 +718,10 @@ gimp_interpreter_db_resolve (GimpInterpreterDB *db,
gssize len;
gchar buffer[BUFSIZE];
g_return_val_if_fail (GIMP_IS_INTERPRETER_DB (db), NULL);
g_return_val_if_fail (program_path != NULL, NULL);
g_return_val_if_fail (interp_arg != NULL, NULL);
*interp_arg = NULL;
fd = g_open (program_path, O_RDONLY | _O_BINARY, 0);
......@@ -737,3 +741,40 @@ gimp_interpreter_db_resolve (GimpInterpreterDB *db,
return resolve_magic (db, program_path, buffer);
}
static void
collect_extensions (const gchar *ext,
const gchar *program G_GNUC_UNUSED,
GString *str)
{
if (str->len)
g_string_append_c (str, G_SEARCHPATH_SEPARATOR);
g_string_append_c (str, '.');
g_string_append (str, ext);
}
/**
* gimp_interpreter_db_get_extensions:
* @db:
*
* Return value: a newly allocated string with all registered file
* extensions separated by %G_SEARCHPATH_SEPARATOR;
* or %NULL if no extensions are registered
**/
gchar *
gimp_interpreter_db_get_extensions (GimpInterpreterDB *db)
{
GString *str;
g_return_val_if_fail (GIMP_IS_INTERPRETER_DB (db), NULL);
if (g_hash_table_size (db->extensions) == 0)
return NULL;
str = g_string_new (NULL);
g_hash_table_foreach (db->extensions, (GHFunc) collect_extensions, str);
return g_string_free (str, FALSE);
}
......@@ -63,6 +63,7 @@ void gimp_interpreter_db_clear (GimpInterpreterDB *db);
gchar * gimp_interpreter_db_resolve (GimpInterpreterDB *db,
const gchar *program_path,
gchar **interp_arg);
gchar * gimp_interpreter_db_get_extensions (GimpInterpreterDB *db);
#endif /* __GIMP_INTERPRETER_DB_H__ */
......@@ -353,7 +353,30 @@ gimp_plug_in_manager_restore (GimpPlugInManager *manager,
/* search for binaries in the plug-in directory path */
{
gchar *path;
gchar *path;
const gchar *pathext = g_getenv ("PATHEXT");
/* If PATHEXT is set, we are likely on Windows and need to add
* the known file extensions.
*/
if (pathext)
{
gchar *exts;
exts = gimp_interpreter_db_get_extensions (manager->interpreter_db);
if (exts)
{
gchar *value;
value = g_strconcat (pathext, G_SEARCHPATH_SEPARATOR_S, exts, NULL);
g_setenv ("PATHEXT", value, TRUE);
g_free (value);
g_free (exts);
}
}
status_callback (_("Searching Plug-Ins"), "", 0.0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment