Updated with upstream update
This commit is contained in:
@ -98,6 +98,9 @@ static GTokenType pika_config_deserialize_file_value (GValue *value,
|
||||
static GTokenType pika_config_deserialize_parasite_value (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
static GTokenType pika_config_deserialize_bytes (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
static GTokenType pika_config_deserialize_any (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner);
|
||||
@ -389,6 +392,10 @@ pika_config_deserialize_value (GValue *value,
|
||||
{
|
||||
return pika_config_deserialize_parasite_value (value, prop_spec, scanner);
|
||||
}
|
||||
else if (prop_spec->value_type == G_TYPE_BYTES)
|
||||
{
|
||||
return pika_config_deserialize_bytes (value, prop_spec, scanner);
|
||||
}
|
||||
|
||||
/* This fallback will only work for value_types that
|
||||
* can be transformed from a string value.
|
||||
@ -1030,6 +1037,52 @@ pika_config_deserialize_parasite_value (GValue *value,
|
||||
return G_TOKEN_RIGHT_PAREN;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
pika_config_deserialize_bytes (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
GScanner *scanner)
|
||||
{
|
||||
GTokenType token;
|
||||
GBytes *bytes;
|
||||
guint8 *data;
|
||||
gint data_length;
|
||||
|
||||
token = g_scanner_peek_next_token (scanner);
|
||||
|
||||
if (token == G_TOKEN_IDENTIFIER)
|
||||
{
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
if (g_ascii_strcasecmp (scanner->value.v_identifier, "null") != 0)
|
||||
/* Do not fail the whole file parsing. Just output to stderr and assume
|
||||
* a NULL bytes property.
|
||||
*/
|
||||
g_printerr ("%s: expected NULL identifier for bytes token '%s', got '%s'. "
|
||||
"Assuming NULL instead.\n",
|
||||
G_STRFUNC, prop_spec->name, scanner->value.v_identifier);
|
||||
|
||||
g_value_set_boxed (value, NULL);
|
||||
}
|
||||
else if (token == G_TOKEN_INT)
|
||||
{
|
||||
if (! pika_scanner_parse_int (scanner, &data_length))
|
||||
return G_TOKEN_INT;
|
||||
|
||||
if (! pika_scanner_parse_data (scanner, data_length, &data))
|
||||
return G_TOKEN_STRING;
|
||||
|
||||
bytes = g_bytes_new (data, data_length);
|
||||
|
||||
g_value_take_boxed (value, bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return G_TOKEN_INT;
|
||||
}
|
||||
|
||||
return G_TOKEN_RIGHT_PAREN;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
pika_config_deserialize_any (GValue *value,
|
||||
GParamSpec *prop_spec,
|
||||
|
@ -240,6 +240,15 @@ pika_config_param_spec_duplicate (GParamSpec *pspec)
|
||||
flags);
|
||||
}
|
||||
}
|
||||
else if (PIKA_IS_PARAM_SPEC_CHOICE (pspec))
|
||||
{
|
||||
PikaParamSpecChoice *spec = PIKA_PARAM_SPEC_CHOICE (pspec);
|
||||
|
||||
copy = pika_param_spec_choice (name, nick, blurb,
|
||||
g_object_ref (spec->choice),
|
||||
spec->default_value,
|
||||
flags);
|
||||
}
|
||||
else if (PIKA_IS_PARAM_SPEC_RGB (pspec))
|
||||
{
|
||||
PikaRGB color;
|
||||
@ -344,8 +353,12 @@ pika_config_param_spec_duplicate (GParamSpec *pspec)
|
||||
g_strcmp0 (type_name, "PikaImage") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaDrawable") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaLayer") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaTextLayer") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaChannel") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaItem") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaLayerMask") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaSelection") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaResource") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaBrush") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaFont") == 0 ||
|
||||
g_strcmp0 (type_name, "PikaGradient") == 0 ||
|
||||
|
@ -275,6 +275,30 @@ pika_config_serialize_property (PikaConfig *config,
|
||||
else
|
||||
pika_config_writer_revert (writer);
|
||||
}
|
||||
else if (G_VALUE_TYPE (&value) == G_TYPE_BYTES)
|
||||
{
|
||||
GBytes *bytes = g_value_get_boxed (&value);
|
||||
|
||||
pika_config_writer_open (writer, param_spec->name);
|
||||
|
||||
if (bytes)
|
||||
{
|
||||
gconstpointer data;
|
||||
gsize data_length;
|
||||
|
||||
data = g_bytes_get_data (bytes, &data_length);
|
||||
|
||||
pika_config_writer_printf (writer, "%lu", data_length);
|
||||
pika_config_writer_data (writer, data_length, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
pika_config_writer_printf (writer, "%s", "NULL");
|
||||
}
|
||||
|
||||
success = TRUE;
|
||||
pika_config_writer_close (writer);
|
||||
}
|
||||
else if (G_VALUE_HOLDS_OBJECT (&value) &&
|
||||
G_VALUE_TYPE (&value) != G_TYPE_FILE)
|
||||
{
|
||||
|
Reference in New Issue
Block a user