[gimp] libgimpbase: new GimpProcedureSensitivityMask type.



commit b1fed22763e51486179908a9466c4d294dc08887
Author: Jehan <jehan girinstud io>
Date:   Thu Apr 1 22:42:54 2021 +0200

    libgimpbase: new GimpProcedureSensitivityMask type.
    
    This will be used by plug-ins to advertize their usage. Until now, we
    were assuming that a plug-in wants a single drawable selected. Yet
    multiple drawables can be selected now. Moreover even this information
    is not so useful as many plug-ins don't care about what is being
    selected. There is possibly even plug-ins which don't care whether an
    image is opened (a plug-in to create new images for instance).
    
    Note that this new type is skipped from the PDB because it is used as a
    mask, hence not necessary, and was breaking script-fu (which was
    incrementing through enums, hence assuming successive int values, not
    bit mask values).

 libgimpbase/gimpbaseenums.c | 36 ++++++++++++++++++++++++++++++++++++
 libgimpbase/gimpbaseenums.h | 22 ++++++++++++++++++++++
 2 files changed, 58 insertions(+)
---
diff --git a/libgimpbase/gimpbaseenums.c b/libgimpbase/gimpbaseenums.c
index 22379e5e1e..50e03fe560 100644
--- a/libgimpbase/gimpbaseenums.c
+++ b/libgimpbase/gimpbaseenums.c
@@ -1376,6 +1376,42 @@ gimp_precision_get_type (void)
   return type;
 }
 
+GType
+gimp_procedure_sensitivity_mask_get_type (void)
+{
+  static const GFlagsValue values[] =
+  {
+    { GIMP_PROCEDURE_SENSITIVE_DRAWABLE, "GIMP_PROCEDURE_SENSITIVE_DRAWABLE", "drawable" },
+    { GIMP_PROCEDURE_SENSITIVE_DRAWABLES, "GIMP_PROCEDURE_SENSITIVE_DRAWABLES", "drawables" },
+    { GIMP_PROCEDURE_SENSITIVE_NO_DRAWABLES, "GIMP_PROCEDURE_SENSITIVE_NO_DRAWABLES", "no-drawables" },
+    { GIMP_PROCEDURE_SENSITIVE_NO_IMAGE, "GIMP_PROCEDURE_SENSITIVE_NO_IMAGE", "no-image" },
+    { GIMP_PROCEDURE_SENSITIVE_ALWAYS, "GIMP_PROCEDURE_SENSITIVE_ALWAYS", "always" },
+    { 0, NULL, NULL }
+  };
+
+  static const GimpFlagsDesc descs[] =
+  {
+    { GIMP_PROCEDURE_SENSITIVE_DRAWABLE, "GIMP_PROCEDURE_SENSITIVE_DRAWABLE", NULL },
+    { GIMP_PROCEDURE_SENSITIVE_DRAWABLES, "GIMP_PROCEDURE_SENSITIVE_DRAWABLES", NULL },
+    { GIMP_PROCEDURE_SENSITIVE_NO_DRAWABLES, "GIMP_PROCEDURE_SENSITIVE_NO_DRAWABLES", NULL },
+    { GIMP_PROCEDURE_SENSITIVE_NO_IMAGE, "GIMP_PROCEDURE_SENSITIVE_NO_IMAGE", NULL },
+    { GIMP_PROCEDURE_SENSITIVE_ALWAYS, "GIMP_PROCEDURE_SENSITIVE_ALWAYS", NULL },
+    { 0, NULL, NULL }
+  };
+
+  static GType type = 0;
+
+  if (G_UNLIKELY (! type))
+    {
+      type = g_flags_register_static ("GimpProcedureSensitivityMask", values);
+      gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");
+      gimp_type_set_translation_context (type, "procedure-sensitivity-mask");
+      gimp_flags_set_value_descriptions (type, descs);
+    }
+
+  return type;
+}
+
 GType
 gimp_progress_command_get_type (void)
 {
diff --git a/libgimpbase/gimpbaseenums.h b/libgimpbase/gimpbaseenums.h
index 3f4e7dd6ac..3e585391ee 100644
--- a/libgimpbase/gimpbaseenums.h
+++ b/libgimpbase/gimpbaseenums.h
@@ -939,6 +939,28 @@ typedef enum
 } GimpPrecision;
 
 
+/**
+ * GimpProcedureSensitivityMask:
+ * @GIMP_PROCEDURE_SENSITIVE_DRAWABLE:     Handles image with one selected drawable.
+ * @GIMP_PROCEDURE_SENSITIVE_DRAWABLES:    Handles image with several selected drawables.
+ * @GIMP_PROCEDURE_SENSITIVE_NO_DRAWABLES: Handles image with no selected drawables.
+ * @GIMP_PROCEDURE_SENSITIVE_NO_IMAGE:     Handles no image.
+ *
+ * The cases when a #GimpProcedure should be shown as sensitive.
+ **/
+#define GIMP_TYPE_PROCEDURE_SENSITIVITY_MASK (gimp_procedure_sensitivity_mask_get_type ())
+
+GType gimp_procedure_sensitivity_mask_get_type (void) G_GNUC_CONST;
+typedef enum  /*< pdb-skip >*/
+{
+  GIMP_PROCEDURE_SENSITIVE_DRAWABLE      = 1 << 0,
+  GIMP_PROCEDURE_SENSITIVE_DRAWABLES     = 1 << 2,
+  GIMP_PROCEDURE_SENSITIVE_NO_DRAWABLES  = 1 << 3,
+  GIMP_PROCEDURE_SENSITIVE_NO_IMAGE      = 1 << 4,
+  GIMP_PROCEDURE_SENSITIVE_ALWAYS        = 0xFFFFFFFF
+} GimpProcedureSensitivityMask;
+
+
 /**
  * GimpProgressCommand:
  * @GIMP_PROGRESS_COMMAND_START:      Start a progress


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