From 2df7874216fd42cc767c6ab9413ed0061d642abc Mon Sep 17 00:00:00 2001 From: bootchk Date: Sat, 6 Apr 2024 14:33:13 -0400 Subject: [PATCH] ScriptFu: hide "Refresh Scripts" It is broken and throws critical, see #10596. Expedient to hide it instead of fixing it, to not block 3.0rc1. As discussed in #10652, a user can simply restart GIMP instead. "Refresh Scripts" is a poor design, a bandaid. There are plans for better alternatives to install/remove scripts. The MR for #10652 shows the reason it throws critical, and could fix it, but completing the MR requires time we don't have. Note the MR is not on these files, but on core plugin machinery. The change is to extract functions to a separate file, and still build them, but not call them or link them. They also are not translated while not being called. Eventually, the extracted files can be deleted (or restored when they work.) There is other related cruft that needs deletion in scheme-wrapper.c. --- plug-ins/script-fu/meson.build | 1 + plug-ins/script-fu/script-fu-refresh.c | 100 +++++++++++++++++++++++++ plug-ins/script-fu/script-fu-refresh.h | 23 ++++++ plug-ins/script-fu/script-fu.c | 62 +-------------- po-script-fu/POTFILES.skip | 1 + 5 files changed, 128 insertions(+), 59 deletions(-) create mode 100644 plug-ins/script-fu/script-fu-refresh.c create mode 100644 plug-ins/script-fu/script-fu-refresh.h diff --git a/plug-ins/script-fu/meson.build b/plug-ins/script-fu/meson.build index 5d5598cbf9..34820e13ef 100644 --- a/plug-ins/script-fu/meson.build +++ b/plug-ins/script-fu/meson.build @@ -24,6 +24,7 @@ executable_name = 'script-fu' plugin_sources = [ 'script-fu-eval.c', 'script-fu-text-console.c', + 'script-fu-refresh.c', 'script-fu.c', ] diff --git a/plug-ins/script-fu/script-fu-refresh.c b/plug-ins/script-fu/script-fu-refresh.c new file mode 100644 index 0000000000..6ad0e4187b --- /dev/null +++ b/plug-ins/script-fu/script-fu-refresh.c @@ -0,0 +1,100 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "config.h" + +#include + +#include + +#include "libscriptfu/script-fu-lib.h" +#include "libscriptfu/script-fu-intl.h" + +/* The "Refresh Scripts" menu item is not in v3. + * + * Code is built, but the linker omits it, + * since one call is commented out. + * + * This is not the only cruft, scheme_wrapper.c references + * the PDB procedure by name. + * + * See #10596 and #10652. + * When used, it throws CRITICAL. + * There is also an MR that fixes the reason for the CRITICAL, + * but #10652 suggests better alternatives. + */ + +static GimpValueArray * +script_fu_refresh_proc (GimpProcedure *procedure, + GimpProcedureConfig *config, + gpointer run_data) +{ + if (script_fu_extension_is_busy ()) + { + g_message (_("You can not use \"Refresh Scripts\" while a " + "Script-Fu dialog box is open. Please close " + "all Script-Fu windows and try again.")); + + return gimp_procedure_new_return_values (procedure, + GIMP_PDB_EXECUTION_ERROR, + NULL); + } + else + { + /* Reload all of the available scripts */ + GList *path = script_fu_search_path (); + + script_fu_find_and_register_scripts (gimp_procedure_get_plug_in (procedure), path); + + g_list_free_full (path, (GDestroyNotify) g_object_unref); + } + + return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL); +} + +void +script_fu_register_refresh_procedure (GimpPlugIn *plug_in) +{ + GimpProcedure *procedure; + + procedure = gimp_procedure_new (plug_in, "script-fu-refresh", + GIMP_PDB_PROC_TYPE_TEMPORARY, + script_fu_refresh_proc, NULL, NULL); + + gimp_procedure_set_menu_label (procedure, _("_Refresh Scripts")); + gimp_procedure_add_menu_path (procedure, + "/Filters/Development/Script-Fu"); + + gimp_procedure_set_documentation (procedure, + _("Re-read all available Script-Fu scripts"), + "Re-read all available Script-Fu scripts", + "script-fu-refresh"); + gimp_procedure_set_attribution (procedure, + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1997"); + + GIMP_PROC_ARG_ENUM (procedure, "run-mode", + "Run mode", + "The run mode", + GIMP_TYPE_RUN_MODE, + GIMP_RUN_INTERACTIVE, + G_PARAM_READWRITE); + + gimp_plug_in_add_temp_procedure (plug_in, procedure); + g_object_unref (procedure); +} \ No newline at end of file diff --git a/plug-ins/script-fu/script-fu-refresh.h b/plug-ins/script-fu/script-fu-refresh.h new file mode 100644 index 0000000000..d1d31173fc --- /dev/null +++ b/plug-ins/script-fu/script-fu-refresh.h @@ -0,0 +1,23 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __SCRIPT_FU_REFRESH_H__ +#define __SCRIPT_FU_REFRESH_H__ + +void script_fu_register_refresh_procedure (GimpPlugIn *plug_in); + +#endif /* __SCRIPT_FU_REFRESH_H__ */ \ No newline at end of file diff --git a/plug-ins/script-fu/script-fu.c b/plug-ins/script-fu/script-fu.c index 00ee6cb608..7279870ba6 100644 --- a/plug-ins/script-fu/script-fu.c +++ b/plug-ins/script-fu/script-fu.c @@ -52,9 +52,6 @@ static GimpValueArray * script_fu_batch_run (GimpProcedure *proced static void script_fu_run_init (GimpProcedure *procedure, GimpRunMode run_mode); static void script_fu_extension_init (GimpPlugIn *plug_in); -static GimpValueArray * script_fu_refresh_proc (GimpProcedure *procedure, - GimpProcedureConfig *config, - gpointer run_data); G_DEFINE_TYPE (ScriptFu, script_fu, GIMP_TYPE_PLUG_IN) @@ -309,8 +306,6 @@ script_fu_run_init (GimpProcedure *procedure, static void script_fu_extension_init (GimpPlugIn *plug_in) { - GimpProcedure *procedure; - gimp_plug_in_add_menu_branch (plug_in, "/Help", N_("_GIMP Online")); gimp_plug_in_add_menu_branch (plug_in, "/Help", N_("_User Manual")); @@ -338,58 +333,7 @@ script_fu_extension_init (GimpPlugIn *plug_in) gimp_plug_in_add_menu_branch (plug_in, "/Filters", N_("Alpha to _Logo")); - procedure = gimp_procedure_new (plug_in, "script-fu-refresh", - GIMP_PDB_PROC_TYPE_TEMPORARY, - script_fu_refresh_proc, NULL, NULL); - - gimp_procedure_set_menu_label (procedure, _("_Refresh Scripts")); - gimp_procedure_add_menu_path (procedure, - "/Filters/Development/Script-Fu"); - - gimp_procedure_set_documentation (procedure, - _("Re-read all available Script-Fu scripts"), - "Re-read all available Script-Fu scripts", - "script-fu-refresh"); - gimp_procedure_set_attribution (procedure, - "Spencer Kimball & Peter Mattis", - "Spencer Kimball & Peter Mattis", - "1997"); - - GIMP_PROC_ARG_ENUM (procedure, "run-mode", - "Run mode", - "The run mode", - GIMP_TYPE_RUN_MODE, - GIMP_RUN_INTERACTIVE, - G_PARAM_READWRITE); - - gimp_plug_in_add_temp_procedure (plug_in, procedure); - g_object_unref (procedure); -} - -static GimpValueArray * -script_fu_refresh_proc (GimpProcedure *procedure, - GimpProcedureConfig *config, - gpointer run_data) -{ - if (script_fu_extension_is_busy ()) - { - g_message (_("You can not use \"Refresh Scripts\" while a " - "Script-Fu dialog box is open. Please close " - "all Script-Fu windows and try again.")); - - return gimp_procedure_new_return_values (procedure, - GIMP_PDB_EXECUTION_ERROR, - NULL); - } - else - { - /* Reload all of the available scripts */ - GList *path = script_fu_search_path (); - - script_fu_find_and_register_scripts (gimp_procedure_get_plug_in (procedure), path); - - g_list_free_full (path, (GDestroyNotify) g_object_unref); - } - - return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL); + /* Commented out until fixed or replaced. + * script_fu_register_refresh_procedure (plug_in); + */ } diff --git a/po-script-fu/POTFILES.skip b/po-script-fu/POTFILES.skip index c581317620..88370e1bca 100644 --- a/po-script-fu/POTFILES.skip +++ b/po-script-fu/POTFILES.skip @@ -49,6 +49,7 @@ plug-ins/pagecurl plug-ins/print plug-ins/python plug-ins/screenshot +plug-ins/script-fu/script-fu-refresh.c plug-ins/script-fu/scripts/contactsheet.scm plug-ins/script-fu/scripts/clothify-v3.scm plug-ins/script-fu/scripts/test-v3.scm