[gimp] libgimp, app: allow usage of GParamSpecString procedure arguments.



commit 2c4a8c89ed803ecee788245e8617ee70191f2381
Author: Jehan <jehan girinstud io>
Date:   Fri Aug 2 15:55:52 2019 +0200

    libgimp, app: allow usage of GParamSpecString procedure arguments.
    
    Just consider these as a GimpParamSpecString with default allow_non_utf8
    and non_empty values (FALSE).

 app/plug-in/gimpgpparams.c  |  3 ++-
 libgimp/gimpgpparams-body.c | 20 +++++++++++++++-----
 2 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/app/plug-in/gimpgpparams.c b/app/plug-in/gimpgpparams.c
index ee19f43c05..5364f5b0b5 100644
--- a/app/plug-in/gimpgpparams.c
+++ b/app/plug-in/gimpgpparams.c
@@ -139,7 +139,8 @@ _gimp_gp_param_def_to_param_spec (Gimp       *gimp,
       break;
 
     case GP_PARAM_DEF_TYPE_STRING:
-      if (! strcmp (param_def->type_name, "GimpParamString"))
+      if (! strcmp (param_def->type_name, "GimpParamString") ||
+          ! strcmp (param_def->type_name, "GParamString"))
         return gimp_param_spec_string (name, nick, blurb,
                                        param_def->meta.m_string.allow_non_utf8,
                                        param_def->meta.m_string.null_ok,
diff --git a/libgimp/gimpgpparams-body.c b/libgimp/gimpgpparams-body.c
index 240ea626f4..8b6ef916e1 100644
--- a/libgimp/gimpgpparams-body.c
+++ b/libgimp/gimpgpparams-body.c
@@ -99,17 +99,27 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
       param_def->meta.m_float.max_val     = dspec->maximum;
       param_def->meta.m_float.default_val = dspec->default_value;
     }
-  else if (pspec_type == GIMP_TYPE_PARAM_STRING)
+  else if (pspec_type == GIMP_TYPE_PARAM_STRING ||
+           pspec_type == G_TYPE_PARAM_STRING)
     {
-      GParamSpecString    *gsspec = G_PARAM_SPEC_STRING (pspec);
-      GimpParamSpecString *sspec  = GIMP_PARAM_SPEC_STRING (pspec);
+      GParamSpecString *gsspec = G_PARAM_SPEC_STRING (pspec);
 
       param_def->param_def_type = GP_PARAM_DEF_TYPE_STRING;
 
-      param_def->meta.m_string.allow_non_utf8 = sspec->allow_non_utf8;
       param_def->meta.m_string.null_ok        = ! gsspec->ensure_non_null;
-      param_def->meta.m_string.non_empty      = sspec->non_empty;
       param_def->meta.m_string.default_val    = gsspec->default_value;
+      if (pspec_type == GIMP_TYPE_PARAM_STRING)
+        {
+          GimpParamSpecString *sspec = GIMP_PARAM_SPEC_STRING (pspec);
+
+          param_def->meta.m_string.allow_non_utf8 = sspec->allow_non_utf8;
+          param_def->meta.m_string.non_empty      = sspec->non_empty;
+        }
+      else
+        {
+          param_def->meta.m_string.allow_non_utf8 = FALSE;
+          param_def->meta.m_string.non_empty      = FALSE;
+        }
     }
   else if (pspec_type == GIMP_TYPE_PARAM_RGB)
     {


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