[gimp] app: allow plugin inside first-level directories of plug-ins folders.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: allow plugin inside first-level directories of plug-ins folders.
- Date: Wed, 24 May 2017 15:34:15 +0000 (UTC)
commit efae55a73e98389e38fa0e59ebebcda0abe3ee96
Author: Jehan <jehan girinstud io>
Date: Wed May 24 12:02:52 2017 +0200
app: allow plugin inside first-level directories of plug-ins folders.
We don't search recursively but only at the first level. If a plugin is
in its own subdirectory, the entry point has to be named the same (minus
extension) as the directory. For instance my-plugin/my-plugin for a
binary, or my-plugin/my-plugin.(py|exe|…).
This way, a plugin can load shared objects (libraries, other script
files, etc.) without polluting the main plug-ins directories, and in
particular without interfering with other plug-ins.
This is a first step to fix bug 757057 (DLL files which were used in
various plugins).
app/plug-in/gimppluginmanager-restore.c | 54 +++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/app/plug-in/gimppluginmanager-restore.c b/app/plug-in/gimppluginmanager-restore.c
index 23b6a24..0f4c58a 100644
--- a/app/plug-in/gimppluginmanager-restore.c
+++ b/app/plug-in/gimppluginmanager-restore.c
@@ -278,6 +278,60 @@ gimp_plug_in_manager_search_directory (GimpPlugInManager *manager,
gimp_plug_in_manager_add_from_file (manager, child, mtime);
}
+ else if (g_file_query_file_type (child,
+ G_FILE_CREATE_NONE,
+ NULL) == G_FILE_TYPE_DIRECTORY)
+ {
+ /* Search in subdirectory the first executable file with the
+ * same name as the directory (except extension).
+ * We don't search recursively, but only at a single level
+ * and assume that there can be only 1 plugin inside a
+ * directory.
+ */
+ GFileEnumerator *enumerator2;
+
+ enumerator2 = g_file_enumerate_children (child,
+ G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN ","
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, NULL);
+ if (enumerator2)
+ {
+ GFileInfo *info2;
+
+ while ((info2 = g_file_enumerator_next_file (enumerator2, NULL, NULL)))
+ {
+ if (! g_file_info_get_is_hidden (info2))
+ {
+ GFile *child2;
+ gchar *file_name;
+ char *ext;
+
+ child2 = g_file_enumerator_get_child (enumerator2, info2);
+ file_name = g_strdup (g_file_info_get_name (info2));
+ ext = strrchr (file_name, '.');
+ if (ext)
+ *ext = '\0';
+ if (g_strcmp0 (file_name, g_file_info_get_name (info)) == 0 &&
+ gimp_file_is_executable (child2))
+ {
+ guint64 mtime;
+
+ mtime = g_file_info_get_attribute_uint64 (info2,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED);
+
+ gimp_plug_in_manager_add_from_file (manager, child2, mtime);
+ break;
+ }
+ g_object_unref (child2);
+ g_free (file_name);
+ }
+ g_object_unref (info2);
+ }
+ }
+ g_object_unref (enumerator2);
+ }
g_object_unref (child);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]