mirror of https://github.com/GNOME/gimp.git
Move GimpParamSpecString from libgimp back to app
It's just too weird to be public. Remove its properties from the wire protocol and from pluginrc. Instead, have all GParamSpecs' flags on the wire and in pluginrc, so we can use stuff like GIMP_PARAM_NO_VALIDATE. Port the remaining few places to GIMP_PROC_ARG_STRING(). I'm sure something is broken now wrt UTF-8 validation, will add tighter checks in the next commit.
This commit is contained in:
parent
de121374ef
commit
d62e75a41f
|
@ -34,6 +34,174 @@
|
|||
#include "vectors/gimpvectors.h"
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_STRING
|
||||
*/
|
||||
|
||||
static void gimp_param_string_class_init (GParamSpecClass *klass);
|
||||
static void gimp_param_string_init (GParamSpec *pspec);
|
||||
static gboolean gimp_param_string_validate (GParamSpec *pspec,
|
||||
GValue *value);
|
||||
|
||||
static GParamSpecClass * gimp_param_string_parent_class = NULL;
|
||||
|
||||
GType
|
||||
gimp_param_string_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
const GTypeInfo info =
|
||||
{
|
||||
sizeof (GParamSpecClass),
|
||||
NULL, NULL,
|
||||
(GClassInitFunc) gimp_param_string_class_init,
|
||||
NULL, NULL,
|
||||
sizeof (GimpParamSpecString),
|
||||
0,
|
||||
(GInstanceInitFunc) gimp_param_string_init
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_PARAM_STRING,
|
||||
"GimpParamString", &info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_param_string_class_init (GParamSpecClass *klass)
|
||||
{
|
||||
gimp_param_string_parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
klass->value_type = G_TYPE_STRING;
|
||||
klass->value_validate = gimp_param_string_validate;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_param_string_init (GParamSpec *pspec)
|
||||
{
|
||||
GimpParamSpecString *sspec = GIMP_PARAM_SPEC_STRING (pspec);
|
||||
|
||||
G_PARAM_SPEC_STRING (pspec)->ensure_non_null = TRUE;
|
||||
|
||||
sspec->allow_non_utf8 = FALSE;
|
||||
sspec->non_empty = FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_param_string_validate (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
GimpParamSpecString *sspec = GIMP_PARAM_SPEC_STRING (pspec);
|
||||
gchar *string = value->data[0].v_pointer;
|
||||
|
||||
if (gimp_param_string_parent_class->value_validate (pspec, value))
|
||||
return TRUE;
|
||||
|
||||
if (string)
|
||||
{
|
||||
gchar *s;
|
||||
|
||||
if (sspec->non_empty && ! string[0])
|
||||
{
|
||||
if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
|
||||
g_free (string);
|
||||
else
|
||||
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
|
||||
|
||||
value->data[0].v_pointer = g_strdup ("none");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (! sspec->allow_non_utf8 &&
|
||||
! g_utf8_validate (string, -1, (const gchar **) &s))
|
||||
{
|
||||
if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
|
||||
{
|
||||
value->data[0].v_pointer = g_strdup (string);
|
||||
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
|
||||
string = value->data[0].v_pointer;
|
||||
}
|
||||
|
||||
for (s = string; *s; s++)
|
||||
if (*s < ' ')
|
||||
*s = '?';
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (sspec->non_empty)
|
||||
{
|
||||
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
|
||||
value->data[0].v_pointer = g_strdup ("none");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_param_spec_string:
|
||||
* @name: Canonical name of the property specified.
|
||||
* @nick: Nick name of the property specified.
|
||||
* @blurb: Description of the property specified.
|
||||
* @allow_non_utf8: Whether non-UTF-8 strings are allowed.
|
||||
* @null_ok: Whether %NULL is allowed.
|
||||
* @non_empty: Whether a non-½NULL value must be set.
|
||||
* @default_value: The default value.
|
||||
* @flags: Flags for the property specified.
|
||||
*
|
||||
* Creates a new #GimpParamSpecString specifying a
|
||||
* #G_TYPE_STRING property.
|
||||
*
|
||||
* If @allow_non_utf8 is %FALSE, non-valid UTF-8 strings will be
|
||||
* replaced by question marks.
|
||||
*
|
||||
* If @null_ok is %FALSE, %NULL strings will be replaced by an empty
|
||||
* string.
|
||||
*
|
||||
* If @non_empty is %TRUE, empty strings will be replaced by `"none"`.
|
||||
*
|
||||
* See g_param_spec_internal() for details on property names.
|
||||
*
|
||||
* Returns: (transfer full): The newly created #GimpParamSpecString.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
GParamSpec *
|
||||
gimp_param_spec_string (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
gboolean allow_non_utf8,
|
||||
gboolean null_ok,
|
||||
gboolean non_empty,
|
||||
const gchar *default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GimpParamSpecString *sspec;
|
||||
|
||||
g_return_val_if_fail (! (null_ok && non_empty), NULL);
|
||||
|
||||
sspec = g_param_spec_internal (GIMP_TYPE_PARAM_STRING,
|
||||
name, nick, blurb, flags);
|
||||
|
||||
if (sspec)
|
||||
{
|
||||
g_free (G_PARAM_SPEC_STRING (sspec)->default_value);
|
||||
G_PARAM_SPEC_STRING (sspec)->default_value = g_strdup (default_value);
|
||||
|
||||
G_PARAM_SPEC_STRING (sspec)->ensure_non_null = null_ok ? FALSE : TRUE;
|
||||
|
||||
sspec->allow_non_utf8 = allow_non_utf8 ? TRUE : FALSE;
|
||||
sspec->non_empty = non_empty ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
return G_PARAM_SPEC (sspec);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_ENUM
|
||||
*/
|
||||
|
|
|
@ -19,6 +19,36 @@
|
|||
#define __APP_GIMP_PARAM_SPECS_H__
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_STRING
|
||||
*/
|
||||
|
||||
#define GIMP_TYPE_PARAM_STRING (gimp_param_string_get_type ())
|
||||
#define GIMP_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_STRING, GimpParamSpecString))
|
||||
#define GIMP_IS_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_STRING))
|
||||
|
||||
typedef struct _GimpParamSpecString GimpParamSpecString;
|
||||
|
||||
struct _GimpParamSpecString
|
||||
{
|
||||
GParamSpecString parent_instance;
|
||||
|
||||
guint allow_non_utf8 : 1;
|
||||
guint non_empty : 1;
|
||||
};
|
||||
|
||||
GType gimp_param_string_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GParamSpec * gimp_param_spec_string (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
gboolean allow_non_utf8,
|
||||
gboolean null_ok,
|
||||
gboolean non_empty,
|
||||
const gchar *default_value,
|
||||
GParamFlags flags);
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_ENUM
|
||||
*/
|
||||
|
|
|
@ -55,7 +55,9 @@ _gimp_gp_param_def_to_param_spec (gpointer gimp,
|
|||
const gchar *name = param_def->name;
|
||||
const gchar *nick = param_def->nick;
|
||||
const gchar *blurb = param_def->blurb;
|
||||
GParamFlags flags = G_PARAM_READWRITE;
|
||||
GParamFlags flags = param_def->flags;
|
||||
|
||||
flags &= ~G_PARAM_STATIC_STRINGS;
|
||||
|
||||
switch (param_def->param_def_type)
|
||||
{
|
||||
|
@ -145,14 +147,10 @@ _gimp_gp_param_def_to_param_spec (gpointer gimp,
|
|||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_STRING:
|
||||
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,
|
||||
param_def->meta.m_string.non_empty,
|
||||
param_def->meta.m_string.default_val,
|
||||
flags);
|
||||
if (! strcmp (param_def->type_name, "GParamString"))
|
||||
return g_param_spec_string (name, nick, blurb,
|
||||
param_def->meta.m_string.default_val,
|
||||
flags);
|
||||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_COLOR:
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define PLUG_IN_RC_FILE_VERSION 10
|
||||
#define PLUG_IN_RC_FILE_VERSION 11
|
||||
|
||||
|
||||
/*
|
||||
|
@ -764,7 +764,8 @@ plug_in_proc_arg_deserialize (GScanner *scanner,
|
|||
if (! gimp_scanner_parse_string (scanner, ¶m_def.type_name) ||
|
||||
! gimp_scanner_parse_string (scanner, ¶m_def.name) ||
|
||||
! gimp_scanner_parse_string (scanner, ¶m_def.nick) ||
|
||||
! gimp_scanner_parse_string (scanner, ¶m_def.blurb))
|
||||
! gimp_scanner_parse_string (scanner, ¶m_def.blurb) ||
|
||||
! gimp_scanner_parse_int (scanner, (gint *) ¶m_def.flags))
|
||||
{
|
||||
token = G_TOKEN_STRING;
|
||||
goto error;
|
||||
|
@ -839,16 +840,6 @@ plug_in_proc_arg_deserialize (GScanner *scanner,
|
|||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_STRING:
|
||||
if (! gimp_scanner_parse_int (scanner,
|
||||
¶m_def.meta.m_string.allow_non_utf8) ||
|
||||
! gimp_scanner_parse_int (scanner,
|
||||
¶m_def.meta.m_string.null_ok) ||
|
||||
! gimp_scanner_parse_int (scanner,
|
||||
¶m_def.meta.m_string.non_empty))
|
||||
{
|
||||
token = G_TOKEN_INT;
|
||||
goto error;
|
||||
}
|
||||
if (! gimp_scanner_parse_string (scanner,
|
||||
¶m_def.meta.m_string.default_val))
|
||||
{
|
||||
|
@ -1017,6 +1008,7 @@ plug_in_rc_write_proc_arg (GimpConfigWriter *writer,
|
|||
gimp_config_writer_string (writer, g_param_spec_get_name (pspec));
|
||||
gimp_config_writer_string (writer, g_param_spec_get_nick (pspec));
|
||||
gimp_config_writer_string (writer, g_param_spec_get_blurb (pspec));
|
||||
gimp_config_writer_printf (writer, "%d", pspec->flags);
|
||||
|
||||
switch (param_def.param_def_type)
|
||||
{
|
||||
|
@ -1066,10 +1058,6 @@ plug_in_rc_write_proc_arg (GimpConfigWriter *writer,
|
|||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_STRING:
|
||||
gimp_config_writer_printf (writer, "%d %d %d",
|
||||
param_def.meta.m_string.allow_non_utf8,
|
||||
param_def.meta.m_string.null_ok,
|
||||
param_def.meta.m_string.non_empty);
|
||||
gimp_config_writer_string (writer,
|
||||
param_def.meta.m_string.default_val);
|
||||
break;
|
||||
|
|
|
@ -296,7 +296,6 @@ GIMP_PARAM_STATIC_STRINGS
|
|||
GIMP_PARAM_READABLE
|
||||
GIMP_PARAM_WRITABLE
|
||||
GIMP_PARAM_READWRITE
|
||||
gimp_param_spec_string
|
||||
gimp_array_new
|
||||
gimp_array_copy
|
||||
gimp_array_free
|
||||
|
@ -387,7 +386,6 @@ GimpParamSpecInt16Array
|
|||
GimpParamSpecInt32Array
|
||||
GimpParamSpecUInt8Array
|
||||
GimpParamSpecRGBArray
|
||||
GimpParamSpecString
|
||||
GimpParamSpecStringArray
|
||||
gimp_array_get_type
|
||||
gimp_float_array_get_type
|
||||
|
|
|
@ -12,7 +12,6 @@ gimp_param_int32_array_get_type
|
|||
gimp_param_uint8_array_get_type
|
||||
gimp_param_rgb_array_get_type
|
||||
gimp_param_string_array_get_type
|
||||
gimp_param_string_get_type
|
||||
gimp_parasite_get_type
|
||||
gimp_rgb_array_get_type
|
||||
gimp_string_array_get_type
|
||||
|
|
|
@ -449,7 +449,7 @@ _gimp_main_internal (GType plug_in_type,
|
|||
G_TYPE_INT, G_TYPE_PARAM_INT,
|
||||
G_TYPE_UCHAR, G_TYPE_PARAM_UCHAR,
|
||||
|
||||
G_TYPE_STRING, GIMP_TYPE_PARAM_STRING,
|
||||
G_TYPE_STRING, G_TYPE_PARAM_STRING,
|
||||
|
||||
GIMP_TYPE_ARRAY, GIMP_TYPE_PARAM_ARRAY,
|
||||
GIMP_TYPE_UINT8_ARRAY, GIMP_TYPE_PARAM_UINT8_ARRAY,
|
||||
|
|
|
@ -70,10 +70,9 @@ _gimp_gp_compat_param_spec (GimpPDBArgType arg_type,
|
|||
break;
|
||||
|
||||
case GIMP_PDB_STRING:
|
||||
pspec = gimp_param_spec_string (name, nick, blurb,
|
||||
TRUE, TRUE, FALSE,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
pspec = g_param_spec_string (name, nick, blurb,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
break;
|
||||
|
||||
case GIMP_PDB_INT32ARRAY:
|
||||
|
|
|
@ -36,6 +36,7 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
|||
param_def->name = (gchar *) g_param_spec_get_name (pspec);
|
||||
param_def->nick = (gchar *) g_param_spec_get_nick (pspec);
|
||||
param_def->blurb = (gchar *) g_param_spec_get_blurb (pspec);
|
||||
param_def->flags = pspec->flags;
|
||||
|
||||
pspec_type = G_PARAM_SPEC_TYPE (pspec);
|
||||
|
||||
|
@ -108,28 +109,17 @@ _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 ||
|
||||
pspec_type == G_TYPE_PARAM_STRING)
|
||||
else if (G_IS_PARAM_SPEC_STRING (pspec))
|
||||
{
|
||||
GParamSpecString *gsspec = G_PARAM_SPEC_STRING (pspec);
|
||||
|
||||
if (! strcmp (param_def->type_name, "GimpParamSpecString"))
|
||||
param_def->type_name = "GParamSpecString";
|
||||
|
||||
param_def->param_def_type = GP_PARAM_DEF_TYPE_STRING;
|
||||
|
||||
param_def->meta.m_string.null_ok = ! gsspec->ensure_non_null;
|
||||
param_def->meta.m_string.default_val = gsspec->default_value;
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,9 @@ _gimp_gp_param_def_to_param_spec (gpointer gimp,
|
|||
const gchar *name = param_def->name;
|
||||
const gchar *nick = param_def->nick;
|
||||
const gchar *blurb = param_def->blurb;
|
||||
GParamFlags flags = G_PARAM_READWRITE;
|
||||
GParamFlags flags = param_def->flags;
|
||||
|
||||
flags &= ~G_PARAM_STATIC_STRINGS;
|
||||
|
||||
switch (param_def->param_def_type)
|
||||
{
|
||||
|
@ -137,14 +139,10 @@ _gimp_gp_param_def_to_param_spec (gpointer gimp,
|
|||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_STRING:
|
||||
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,
|
||||
param_def->meta.m_string.non_empty,
|
||||
param_def->meta.m_string.default_val,
|
||||
flags);
|
||||
if (! strcmp (param_def->type_name, "GParamString"))
|
||||
return g_param_spec_string (name, nick, blurb,
|
||||
param_def->meta.m_string.default_val,
|
||||
flags);
|
||||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_COLOR:
|
||||
|
|
|
@ -79,22 +79,17 @@ gimp_load_procedure_constructed (GObject *object)
|
|||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("uri",
|
||||
"URI",
|
||||
"The URI of the file "
|
||||
"to load",
|
||||
FALSE, FALSE, TRUE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("raw-uri",
|
||||
"Raw URI",
|
||||
"The URI of the file "
|
||||
"to load",
|
||||
FALSE, FALSE, TRUE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "uri",
|
||||
"URI",
|
||||
"The URI of the file to load",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_STRING (procedure, "raw-uri",
|
||||
"Raw URI",
|
||||
"The URI of the file to load",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_VAL_IMAGE (procedure, "image",
|
||||
"Image",
|
||||
|
|
|
@ -84,27 +84,21 @@ gimp_save_procedure_constructed (GObject *object)
|
|||
|
||||
GIMP_PROC_ARG_DRAWABLE (procedure, "drawable",
|
||||
"Drawable",
|
||||
"The drawable "
|
||||
"to save",
|
||||
"The drawable to save",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("uri",
|
||||
"URI",
|
||||
"The URI of the file "
|
||||
"to save to",
|
||||
FALSE, FALSE, TRUE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("raw-uri",
|
||||
"Raw URI",
|
||||
"The URI of the file "
|
||||
"to save to",
|
||||
FALSE, FALSE, TRUE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "uri",
|
||||
"URI",
|
||||
"The URI of the file to save to",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_STRING (procedure, "raw-uri",
|
||||
"Raw URI",
|
||||
"The URI of the file to save to",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -118,13 +118,11 @@ EXPORTS
|
|||
gimp_param_spec_memsize
|
||||
gimp_param_spec_parasite
|
||||
gimp_param_spec_rgb_array
|
||||
gimp_param_spec_string
|
||||
gimp_param_spec_string_array
|
||||
gimp_param_spec_uint8_array
|
||||
gimp_param_spec_unit
|
||||
gimp_param_spec_value_array
|
||||
gimp_param_string_array_get_type
|
||||
gimp_param_string_get_type
|
||||
gimp_param_uint8_array_get_type
|
||||
gimp_param_unit_get_type
|
||||
gimp_param_value_array_get_type
|
||||
|
|
|
@ -25,174 +25,6 @@
|
|||
#include "gimpbase.h"
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_STRING
|
||||
*/
|
||||
|
||||
static void gimp_param_string_class_init (GParamSpecClass *klass);
|
||||
static void gimp_param_string_init (GParamSpec *pspec);
|
||||
static gboolean gimp_param_string_validate (GParamSpec *pspec,
|
||||
GValue *value);
|
||||
|
||||
static GParamSpecClass * gimp_param_string_parent_class = NULL;
|
||||
|
||||
GType
|
||||
gimp_param_string_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
const GTypeInfo info =
|
||||
{
|
||||
sizeof (GParamSpecClass),
|
||||
NULL, NULL,
|
||||
(GClassInitFunc) gimp_param_string_class_init,
|
||||
NULL, NULL,
|
||||
sizeof (GimpParamSpecString),
|
||||
0,
|
||||
(GInstanceInitFunc) gimp_param_string_init
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_PARAM_STRING,
|
||||
"GimpParamString", &info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_param_string_class_init (GParamSpecClass *klass)
|
||||
{
|
||||
gimp_param_string_parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
klass->value_type = G_TYPE_STRING;
|
||||
klass->value_validate = gimp_param_string_validate;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_param_string_init (GParamSpec *pspec)
|
||||
{
|
||||
GimpParamSpecString *sspec = GIMP_PARAM_SPEC_STRING (pspec);
|
||||
|
||||
G_PARAM_SPEC_STRING (pspec)->ensure_non_null = TRUE;
|
||||
|
||||
sspec->allow_non_utf8 = FALSE;
|
||||
sspec->non_empty = FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_param_string_validate (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
GimpParamSpecString *sspec = GIMP_PARAM_SPEC_STRING (pspec);
|
||||
gchar *string = value->data[0].v_pointer;
|
||||
|
||||
if (gimp_param_string_parent_class->value_validate (pspec, value))
|
||||
return TRUE;
|
||||
|
||||
if (string)
|
||||
{
|
||||
gchar *s;
|
||||
|
||||
if (sspec->non_empty && ! string[0])
|
||||
{
|
||||
if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
|
||||
g_free (string);
|
||||
else
|
||||
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
|
||||
|
||||
value->data[0].v_pointer = g_strdup ("none");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (! sspec->allow_non_utf8 &&
|
||||
! g_utf8_validate (string, -1, (const gchar **) &s))
|
||||
{
|
||||
if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
|
||||
{
|
||||
value->data[0].v_pointer = g_strdup (string);
|
||||
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
|
||||
string = value->data[0].v_pointer;
|
||||
}
|
||||
|
||||
for (s = string; *s; s++)
|
||||
if (*s < ' ')
|
||||
*s = '?';
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (sspec->non_empty)
|
||||
{
|
||||
value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
|
||||
value->data[0].v_pointer = g_strdup ("none");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_param_spec_string:
|
||||
* @name: Canonical name of the property specified.
|
||||
* @nick: Nick name of the property specified.
|
||||
* @blurb: Description of the property specified.
|
||||
* @allow_non_utf8: Whether non-UTF-8 strings are allowed.
|
||||
* @null_ok: Whether %NULL is allowed.
|
||||
* @non_empty: Whether a non-½NULL value must be set.
|
||||
* @default_value: The default value.
|
||||
* @flags: Flags for the property specified.
|
||||
*
|
||||
* Creates a new #GimpParamSpecString specifying a
|
||||
* #G_TYPE_STRING property.
|
||||
*
|
||||
* If @allow_non_utf8 is %FALSE, non-valid UTF-8 strings will be
|
||||
* replaced by question marks.
|
||||
*
|
||||
* If @null_ok is %FALSE, %NULL strings will be replaced by an empty
|
||||
* string.
|
||||
*
|
||||
* If @non_empty is %TRUE, empty strings will be replaced by `"none"`.
|
||||
*
|
||||
* See g_param_spec_internal() for details on property names.
|
||||
*
|
||||
* Returns: (transfer full): The newly created #GimpParamSpecString.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
GParamSpec *
|
||||
gimp_param_spec_string (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
gboolean allow_non_utf8,
|
||||
gboolean null_ok,
|
||||
gboolean non_empty,
|
||||
const gchar *default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GimpParamSpecString *sspec;
|
||||
|
||||
g_return_val_if_fail (! (null_ok && non_empty), NULL);
|
||||
|
||||
sspec = g_param_spec_internal (GIMP_TYPE_PARAM_STRING,
|
||||
name, nick, blurb, flags);
|
||||
|
||||
if (sspec)
|
||||
{
|
||||
g_free (G_PARAM_SPEC_STRING (sspec)->default_value);
|
||||
G_PARAM_SPEC_STRING (sspec)->default_value = g_strdup (default_value);
|
||||
|
||||
G_PARAM_SPEC_STRING (sspec)->ensure_non_null = null_ok ? FALSE : TRUE;
|
||||
|
||||
sspec->allow_non_utf8 = allow_non_utf8 ? TRUE : FALSE;
|
||||
sspec->non_empty = non_empty ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
return G_PARAM_SPEC (sspec);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_ARRAY
|
||||
*/
|
||||
|
|
|
@ -74,36 +74,6 @@ G_BEGIN_DECLS
|
|||
GIMP_PARAM_STATIC_STRINGS)
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_PARAM_STRING
|
||||
*/
|
||||
|
||||
#define GIMP_TYPE_PARAM_STRING (gimp_param_string_get_type ())
|
||||
#define GIMP_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_STRING, GimpParamSpecString))
|
||||
#define GIMP_IS_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_STRING))
|
||||
|
||||
typedef struct _GimpParamSpecString GimpParamSpecString;
|
||||
|
||||
struct _GimpParamSpecString
|
||||
{
|
||||
GParamSpecString parent_instance;
|
||||
|
||||
guint allow_non_utf8 : 1;
|
||||
guint non_empty : 1;
|
||||
};
|
||||
|
||||
GType gimp_param_string_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GParamSpec * gimp_param_spec_string (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
gboolean allow_non_utf8,
|
||||
gboolean null_ok,
|
||||
gboolean non_empty,
|
||||
const gchar *default_value,
|
||||
GParamFlags flags);
|
||||
|
||||
|
||||
/*
|
||||
* GIMP_TYPE_ARRAY
|
||||
*/
|
||||
|
|
|
@ -1043,6 +1043,11 @@ _gp_param_def_read (GIOChannel *channel,
|
|||
user_data))
|
||||
return FALSE;
|
||||
|
||||
if (! _gimp_wire_read_int32 (channel,
|
||||
¶m_def->flags, 1,
|
||||
user_data))
|
||||
return FALSE;
|
||||
|
||||
switch (param_def->param_def_type)
|
||||
{
|
||||
case GP_PARAM_DEF_TYPE_DEFAULT:
|
||||
|
@ -1105,16 +1110,7 @@ _gp_param_def_read (GIOChannel *channel,
|
|||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_STRING:
|
||||
if (! _gimp_wire_read_int32 (channel,
|
||||
(guint32 *) ¶m_def->meta.m_string.allow_non_utf8, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_read_int32 (channel,
|
||||
(guint32 *) ¶m_def->meta.m_string.null_ok, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_read_int32 (channel,
|
||||
(guint32 *) ¶m_def->meta.m_string.non_empty, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_read_string (channel,
|
||||
if (! _gimp_wire_read_string (channel,
|
||||
¶m_def->meta.m_string.default_val, 1,
|
||||
user_data))
|
||||
return FALSE;
|
||||
|
@ -1325,6 +1321,11 @@ _gp_param_def_write (GIOChannel *channel,
|
|||
user_data))
|
||||
return FALSE;
|
||||
|
||||
if (! _gimp_wire_write_int32 (channel,
|
||||
¶m_def->flags, 1,
|
||||
user_data))
|
||||
return FALSE;
|
||||
|
||||
switch (param_def->param_def_type)
|
||||
{
|
||||
case GP_PARAM_DEF_TYPE_DEFAULT:
|
||||
|
@ -1387,16 +1388,7 @@ _gp_param_def_write (GIOChannel *channel,
|
|||
break;
|
||||
|
||||
case GP_PARAM_DEF_TYPE_STRING:
|
||||
if (! _gimp_wire_write_int32 (channel,
|
||||
(guint32 *) ¶m_def->meta.m_string.allow_non_utf8, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_int32 (channel,
|
||||
(guint32 *) ¶m_def->meta.m_string.null_ok, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_int32 (channel,
|
||||
(guint32 *) ¶m_def->meta.m_string.non_empty, 1,
|
||||
user_data) ||
|
||||
! _gimp_wire_write_string (channel,
|
||||
if (! _gimp_wire_write_string (channel,
|
||||
¶m_def->meta.m_string.default_val, 1,
|
||||
user_data))
|
||||
return FALSE;
|
||||
|
|
|
@ -26,7 +26,7 @@ G_BEGIN_DECLS
|
|||
|
||||
/* Increment every time the protocol changes
|
||||
*/
|
||||
#define GIMP_PROTOCOL_VERSION 0x0108
|
||||
#define GIMP_PROTOCOL_VERSION 0x0109
|
||||
|
||||
|
||||
enum
|
||||
|
@ -175,9 +175,6 @@ struct _GPParamDefFloat
|
|||
|
||||
struct _GPParamDefString
|
||||
{
|
||||
gint32 allow_non_utf8;
|
||||
gint32 null_ok;
|
||||
gint32 non_empty;
|
||||
gchar *default_val;
|
||||
};
|
||||
|
||||
|
@ -204,6 +201,7 @@ struct _GPParamDef
|
|||
gchar *name;
|
||||
gchar *nick;
|
||||
gchar *blurb;
|
||||
guint flags;
|
||||
|
||||
union
|
||||
{
|
||||
|
|
|
@ -161,14 +161,11 @@ gbr_create_procedure (GimpPlugIn *plug_in,
|
|||
1, 1000, 10,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("description",
|
||||
"Description",
|
||||
"Short description "
|
||||
"of the brush",
|
||||
FALSE, FALSE, TRUE,
|
||||
"GIMP Brush",
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "description",
|
||||
"Description",
|
||||
"Short description of the brush",
|
||||
"GIMP Brush",
|
||||
GIMP_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
return procedure;
|
||||
|
|
|
@ -208,14 +208,12 @@ gif_create_procedure (GimpPlugIn *plug_in,
|
|||
"Sven Neumann",
|
||||
"2006");
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("filename",
|
||||
"Filename",
|
||||
"Name of the file "
|
||||
"to load",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "uri",
|
||||
"URI",
|
||||
"URI of the file to load",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "thumb-size",
|
||||
"Thumb Size",
|
||||
"Preferred thumbnail size",
|
||||
|
@ -305,16 +303,16 @@ gif_load_thumb (GimpProcedure *procedure,
|
|||
gpointer run_data)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
const gchar *filename;
|
||||
GFile *file;
|
||||
gint32 image_id;
|
||||
GError *error = NULL;
|
||||
|
||||
INIT_I18N ();
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
filename = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
|
||||
|
||||
image_id = load_image (filename, TRUE, &error);
|
||||
image_id = load_image (g_file_get_path (file), TRUE, &error);
|
||||
|
||||
if (image_id < 1)
|
||||
return gimp_procedure_new_return_values (procedure,
|
||||
|
|
|
@ -204,14 +204,12 @@ gih_create_procedure (GimpPlugIn *plug_in,
|
|||
1, 1000, 10,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("description",
|
||||
"Description",
|
||||
"Short description "
|
||||
"of the gihtern",
|
||||
FALSE, TRUE, FALSE,
|
||||
"GIMP Gihtern",
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "description",
|
||||
"Description",
|
||||
"Short description of the gihtern",
|
||||
"GIMP Gihtern",
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "cell-width",
|
||||
"Cell width",
|
||||
"Width of the brush cells",
|
||||
|
|
|
@ -127,14 +127,11 @@ pat_create_procedure (GimpPlugIn *plug_in,
|
|||
gimp_file_procedure_set_handles_remote (GIMP_FILE_PROCEDURE (procedure),
|
||||
TRUE);
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("description",
|
||||
"Description",
|
||||
"Short description "
|
||||
"of the pattern",
|
||||
FALSE, TRUE, FALSE,
|
||||
"GIMP Pattern",
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "description",
|
||||
"Description",
|
||||
"Short description of the pattern",
|
||||
"GIMP Pattern",
|
||||
GIMP_PARAM_READWRITE);
|
||||
}
|
||||
|
||||
return procedure;
|
||||
|
|
|
@ -473,14 +473,12 @@ ps_create_procedure (GimpPlugIn *plug_in,
|
|||
"Peter Kirchgessner",
|
||||
dversion);
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("filename",
|
||||
"Filename",
|
||||
"Name of the file "
|
||||
"to load",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "uri",
|
||||
"URI",
|
||||
"URI of the file to load",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "thumb-size",
|
||||
"Thumb Size",
|
||||
"Preferred thumbnail size",
|
||||
|
@ -693,7 +691,7 @@ ps_load_thumb (GimpProcedure *procedure,
|
|||
gpointer run_data)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
const gchar *filename;
|
||||
GFile *file;
|
||||
gint size;
|
||||
gint32 image_id;
|
||||
GError *error = NULL;
|
||||
|
@ -701,8 +699,9 @@ ps_load_thumb (GimpProcedure *procedure,
|
|||
INIT_I18N ();
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
filename = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
size = g_value_get_int (gimp_value_array_index (args, 1));
|
||||
file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
|
||||
|
||||
size = g_value_get_int (gimp_value_array_index (args, 1));
|
||||
|
||||
/* We should look for an embedded preview but for now we
|
||||
* just load the document at a small resolution and the
|
||||
|
@ -715,7 +714,7 @@ ps_load_thumb (GimpProcedure *procedure,
|
|||
|
||||
check_load_vals ();
|
||||
|
||||
image_id = load_image (filename, &error);
|
||||
image_id = load_image (g_file_get_path (file), &error);
|
||||
|
||||
if (image_id < 1)
|
||||
return gimp_procedure_new_return_values (procedure,
|
||||
|
|
|
@ -216,14 +216,11 @@ svg_create_procedure (GimpPlugIn *plug_in,
|
|||
"Dom Lachowicz <cinamod@hotmail.com>",
|
||||
SVG_VERSION);
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("filename",
|
||||
"Filename",
|
||||
"Name of the file "
|
||||
"to load",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "uri",
|
||||
"URI",
|
||||
"URI of the file to load",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "thumb-size",
|
||||
"Thumb Size",
|
||||
|
@ -332,7 +329,7 @@ svg_load_thumb (GimpProcedure *procedure,
|
|||
gpointer run_data)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
const gchar *filename;
|
||||
GFile *file;
|
||||
gint width = 0;
|
||||
gint height = 0;
|
||||
gint32 image_id;
|
||||
|
@ -341,9 +338,10 @@ svg_load_thumb (GimpProcedure *procedure,
|
|||
INIT_I18N ();
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
filename = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
|
||||
|
||||
if (load_rsvg_size (filename, &load_vals, NULL))
|
||||
if (load_rsvg_size (g_file_get_path (file),
|
||||
&load_vals, NULL))
|
||||
{
|
||||
width = load_vals.width;
|
||||
height = load_vals.height;
|
||||
|
@ -353,7 +351,8 @@ svg_load_thumb (GimpProcedure *procedure,
|
|||
load_vals.width = - g_value_get_int (gimp_value_array_index (args, 1));
|
||||
load_vals.height = - g_value_get_int (gimp_value_array_index (args, 1));
|
||||
|
||||
image_id = load_image (filename, &error);
|
||||
image_id = load_image (g_file_get_path (file),
|
||||
&error);
|
||||
|
||||
if (image_id < 1)
|
||||
return gimp_procedure_new_return_values (procedure,
|
||||
|
|
|
@ -156,14 +156,12 @@ ico_create_procedure (GimpPlugIn *plug_in,
|
|||
"Sven Neumann <sven@gimp.org>",
|
||||
"2005");
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("filename",
|
||||
"Filename",
|
||||
"Name of the file "
|
||||
"to load",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "uri",
|
||||
"URI",
|
||||
"URI of the file to load",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "thumb-size",
|
||||
"Thumb Size",
|
||||
"Preferred thumbnail size",
|
||||
|
|
|
@ -186,14 +186,12 @@ psd_create_procedure (GimpPlugIn *plug_in,
|
|||
"John Marshall",
|
||||
"2007");
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("filename",
|
||||
"Filename",
|
||||
"Name of the file "
|
||||
"to load",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "uri",
|
||||
"URI",
|
||||
"URI of the file to load",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "thumb-size",
|
||||
"Thumb Size",
|
||||
"Preferred thumbnail size",
|
||||
|
|
|
@ -239,14 +239,11 @@ darktable_create_procedure (GimpPlugIn *plug_in,
|
|||
"Tobias Ellinghaus",
|
||||
"2016");
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("filename",
|
||||
"Filename",
|
||||
"Name of the file "
|
||||
"to load",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "uri",
|
||||
"URI",
|
||||
"URI of the file to load",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "thumb-size",
|
||||
"Thumb Size",
|
||||
|
@ -369,7 +366,7 @@ darktable_load_thumb (GimpProcedure *procedure,
|
|||
gpointer run_data)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
const gchar *filename;
|
||||
GFile *file;
|
||||
gint width;
|
||||
gint height;
|
||||
gint32 image_id;
|
||||
|
@ -378,11 +375,13 @@ darktable_load_thumb (GimpProcedure *procedure,
|
|||
|
||||
INIT_I18N ();
|
||||
|
||||
filename = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
width = g_value_get_int (gimp_value_array_index (args, 1));
|
||||
height = width;
|
||||
file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
|
||||
|
||||
image_id = load_thumbnail_image (filename, width, &width, &height, &error);
|
||||
width = g_value_get_int (gimp_value_array_index (args, 1));
|
||||
height = width;
|
||||
|
||||
image_id = load_thumbnail_image (g_file_get_path (file),
|
||||
width, &width, &height, &error);
|
||||
|
||||
if (image_id < 1)
|
||||
return gimp_procedure_new_return_values (procedure,
|
||||
|
|
|
@ -190,14 +190,12 @@ rawtherapee_create_procedure (GimpPlugIn *plug_in,
|
|||
"Alberto Griggio",
|
||||
"2017");
|
||||
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("filename",
|
||||
"Filename",
|
||||
"Name of the file "
|
||||
"to load",
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
GIMP_PROC_ARG_STRING (procedure, "uri",
|
||||
"URI",
|
||||
"URI of the file to load",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "thumb-size",
|
||||
"Thumb Size",
|
||||
"Preferred thumbnail size",
|
||||
|
@ -307,7 +305,7 @@ rawtherapee_load_thumb (GimpProcedure *procedure,
|
|||
gpointer run_data)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
const gchar *filename;
|
||||
GFile *file;
|
||||
gint size;
|
||||
gint32 image_id;
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
@ -315,10 +313,12 @@ rawtherapee_load_thumb (GimpProcedure *procedure,
|
|||
|
||||
INIT_I18N ();
|
||||
|
||||
filename = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
size = g_value_get_int (gimp_value_array_index (args, 1));
|
||||
file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
|
||||
|
||||
image_id = load_thumbnail_image (filename, size, &error);
|
||||
size = g_value_get_int (gimp_value_array_index (args, 1));
|
||||
|
||||
image_id = load_thumbnail_image (g_file_get_path (file),
|
||||
size, &error);
|
||||
|
||||
if (image_id < 1)
|
||||
return gimp_procedure_new_return_values (procedure,
|
||||
|
|
|
@ -303,66 +303,61 @@ script_fu_script_install_proc (GimpPlugIn *plug_in,
|
|||
break;
|
||||
|
||||
case SF_FILENAME:
|
||||
pspec = gimp_param_spec_string ("filename",
|
||||
"Filename",
|
||||
script->args[i].label,
|
||||
TRUE, TRUE, FALSE,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
pspec = g_param_spec_string ("filename",
|
||||
"Filename",
|
||||
script->args[i].label,
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
GIMP_PARAM_NO_VALIDATE);
|
||||
break;
|
||||
|
||||
case SF_DIRNAME:
|
||||
pspec = gimp_param_spec_string ("dirname",
|
||||
"Dirname",
|
||||
script->args[i].label,
|
||||
TRUE, TRUE, FALSE,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
pspec = g_param_spec_string ("dirname",
|
||||
"Dirname",
|
||||
script->args[i].label,
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
GIMP_PARAM_NO_VALIDATE);
|
||||
break;
|
||||
|
||||
case SF_FONT:
|
||||
pspec = gimp_param_spec_string ("Font",
|
||||
"font",
|
||||
script->args[i].label,
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
pspec = g_param_spec_string ("Font",
|
||||
"font",
|
||||
script->args[i].label,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
pspec = gimp_param_spec_string ("palette",
|
||||
"Palette",
|
||||
script->args[i].label,
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
pspec = g_param_spec_string ("palette",
|
||||
"Palette",
|
||||
script->args[i].label,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
pspec = gimp_param_spec_string ("pattern",
|
||||
"Pattern",
|
||||
script->args[i].label,
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
pspec = g_param_spec_string ("pattern",
|
||||
"Pattern",
|
||||
script->args[i].label,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
break;
|
||||
|
||||
case SF_BRUSH:
|
||||
pspec = gimp_param_spec_string ("brush",
|
||||
"Brush",
|
||||
script->args[i].label,
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
pspec = g_param_spec_string ("brush",
|
||||
"Brush",
|
||||
script->args[i].label,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
break;
|
||||
|
||||
case SF_GRADIENT:
|
||||
pspec = gimp_param_spec_string ("gradient",
|
||||
"Gradient",
|
||||
script->args[i].label,
|
||||
FALSE, TRUE, FALSE,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
pspec = g_param_spec_string ("gradient",
|
||||
"Gradient",
|
||||
script->args[i].label,
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
break;
|
||||
|
||||
case SF_OPTION:
|
||||
|
|
Loading…
Reference in New Issue