[gimp/gimp-2-10] app: don't reject toolrc files due to missing experimental tools



commit 1156b1e89eb88e33372f16b5df65d89ea1cd4801
Author: Ell <ell_se yahoo com>
Date:   Wed Feb 5 00:03:13 2020 +0200

    app: don't reject toolrc files due to missing experimental tools
    
    Add a new GimpToolInfo::experimental boolean field, and mark
    GimpNPointDeformationTool and GimpSeamlessCloneTool as
    experimental.  In gimp_tools_deserialize(), don't reject the file
    if the only missing tools are experimental, but rather add them to
    the passed container.  In particular, this prevents us from
    rejecting the default toolrc file when experimental tools are
    enabled.
    
    (cherry picked from commit 9f298f767f3bb1dc24493bfd600098e30679bf50)

 app/tools/gimp-tools.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/app/tools/gimp-tools.c b/app/tools/gimp-tools.c
index dccf79acfb..7c35be9e46 100644
--- a/app/tools/gimp-tools.c
+++ b/app/tools/gimp-tools.c
@@ -543,11 +543,26 @@ gimp_tools_deserialize (Gimp          *gimp,
 
           if (! tool_info->hidden && ! g_hash_table_contains (tools, tool_info))
             {
-              g_scanner_error (scanner, "missing tools in toolrc file");
+              if (tool_info->experimental)
+                {
+                  /* if an experimental tool is not in the file, just add it to
+                   * the tool-item list.
+                   */
+                  gimp_container_add (container, GIMP_OBJECT (tool_info));
+                }
+              else
+                {
+                  /* otherwise, it means we added a new stable tool.  this must
+                   * be the user toolrc file; rejct it, so that we fall back to
+                   * the default toolrc file, which should contain the missing
+                   * tool.
+                   */
+                  g_scanner_error (scanner, "missing tools in toolrc file");
 
-              result = FALSE;
+                  result = FALSE;
 
-              break;
+                  break;
+                }
             }
         }
 
@@ -734,6 +749,13 @@ gimp_tools_register (GType                   tool_type,
   if (tool_type == GIMP_TYPE_OPERATION_TOOL)
     tool_info->hidden = TRUE;
 
+  /* hack to not require experimental tools to be present in toolrc */
+  if (tool_type == GIMP_TYPE_N_POINT_DEFORMATION_TOOL ||
+      tool_type == GIMP_TYPE_SEAMLESS_CLONE_TOOL)
+    {
+      tool_info->experimental = TRUE;
+    }
+
   g_object_set_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func",
                      options_gui_func);
 


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