[gimp-perl] call gimp_plugin_menu_register



commit 760147b4ad5929b2748c3e948e6d667ad43093a1
Author: Ed J <mohawk2 users noreply github com>
Date:   Sat Apr 17 19:31:19 2021 +0100

    call gimp_plugin_menu_register

 Changes         |  3 ++-
 lib/Gimp.pm     |  3 +++
 lib/Gimp/Lib.xs | 16 ++++++++++++++--
 3 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/Changes b/Changes
index 7addb6be..56b12496 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,5 @@
-Revision history for Perl module Gimp
+- updated constants to GIMP 2.10 versions
+- remove menu path up to last / and call gimp_plugin_menu_register with that
 
 2.33 2019-04-11
  - Makefile.PL survive non-conf deps so can say what deps are
diff --git a/lib/Gimp.pm b/lib/Gimp.pm
index 7824158b..87ea7d93 100644
--- a/lib/Gimp.pm
+++ b/lib/Gimp.pm
@@ -959,6 +959,9 @@ C<[PARAM_TYPE, "NAME", "DESCRIPTION"]>, e.g.:
      );
   };
 
+This will remove the full menu path (up to the last C</>) and call
+C<gimp_plugin_menu_register> with it behind the scenes.
+
 =head3 Gimp::Progress->init(message,[display])
 
 =head3 Gimp::Progress->update(percentage)
diff --git a/lib/Gimp/Lib.xs b/lib/Gimp/Lib.xs
index 478d692b..57728b52 100644
--- a/lib/Gimp/Lib.xs
+++ b/lib/Gimp/Lib.xs
@@ -1645,6 +1645,16 @@ CODE:
   GimpParamDef *rpd; int nreturn_vals;
   nparams      = convert_array2paramdef ((AV *)SvRV(params)     , &apd);
   nreturn_vals = convert_array2paramdef ((AV *)SvRV(return_vals), &rpd);
+  /* 3 cases: no path, no slash, yes slash */
+  char *menu_location = SvPv(menu_path) ? g_strdup(SvPv(menu_path)) : NULL;
+  char *slash_ptr = menu_location ? g_strrstr(menu_location, "/") : NULL;
+  char *menu_name;
+  if (slash_ptr) {
+    *slash_ptr++ = '\0';
+    menu_name = slash_ptr;
+  } else {
+    menu_name = menu_location;
+  }
   if (ix)
     gimp_install_temp_proc(
       name,
@@ -1653,7 +1663,7 @@ CODE:
       author,
       copyright,
       date,
-      SvPv(menu_path),
+      menu_name,
       SvPv(image_types),
       type,
       nparams,
@@ -1671,7 +1681,7 @@ CODE:
       author,
       copyright,
       date,
-      SvPv(menu_path),
+      menu_name,
       SvPv(image_types),
       type,
       nparams,
@@ -1682,6 +1692,8 @@ CODE:
   }
   g_free (rpd);
   g_free (apd);
+  if (slash_ptr) gimp_plugin_menu_register(name, menu_location);
+  if (menu_location) g_free(menu_location);
 
 void
 gimp_uninstall_temp_proc(name)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]