GVariant: add bind map for strings to byte arrays

This commit is contained in:
Ryan Lortie 2010-04-25 19:10:44 -05:00
parent a52b6f7df2
commit 5e6e7cbadf

View File

@ -369,6 +369,8 @@ g_settings_set_mapping (const GValue *value,
return NULL; return NULL;
else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING)) else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_STRING))
return g_variant_new_string (g_value_get_string (value)); return g_variant_new_string (g_value_get_string (value));
else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE ("ay")))
return g_variant_new_byte_array (g_value_get_string (value), -1);
else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_OBJECT_PATH)) else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_OBJECT_PATH))
return g_variant_new_object_path (g_value_get_string (value)); return g_variant_new_object_path (g_value_get_string (value));
else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_SIGNATURE)) else if (g_variant_type_equal (expected_type, G_VARIANT_TYPE_SIGNATURE))
@ -427,6 +429,11 @@ g_settings_get_mapping (GValue *value,
g_value_set_string (value, g_variant_get_string (variant, NULL)); g_value_set_string (value, g_variant_get_string (variant, NULL));
return TRUE; return TRUE;
} }
else if (g_variant_is_of_type (variant, G_VARIANT_TYPE ("ay")))
{
g_value_set_string (value, g_variant_get_byte_array (variant, NULL));
return TRUE;
}
g_critical ("No GSettings bind handler for type \"%s\".", g_critical ("No GSettings bind handler for type \"%s\".",
g_variant_get_type_string (variant)); g_variant_get_type_string (variant));
@ -460,6 +467,7 @@ g_settings_mapping_is_compatible (GType gvalue_type,
g_variant_type_equal (variant_type, G_VARIANT_TYPE_DOUBLE)); g_variant_type_equal (variant_type, G_VARIANT_TYPE_DOUBLE));
else if (gvalue_type == G_TYPE_STRING) else if (gvalue_type == G_TYPE_STRING)
ok = (g_variant_type_equal (variant_type, G_VARIANT_TYPE_STRING) || ok = (g_variant_type_equal (variant_type, G_VARIANT_TYPE_STRING) ||
g_variant_type_equal (variant_type, G_VARIANT_TYPE ("ay")) ||
g_variant_type_equal (variant_type, G_VARIANT_TYPE_OBJECT_PATH) || g_variant_type_equal (variant_type, G_VARIANT_TYPE_OBJECT_PATH) ||
g_variant_type_equal (variant_type, G_VARIANT_TYPE_SIGNATURE)); g_variant_type_equal (variant_type, G_VARIANT_TYPE_SIGNATURE));