void eel_gconf_value_set_string_list (GConfValue *value, const GSList *string_list) { const GSList *node; GConfValue *next_value; GSList *value_list; g_return_if_fail (value->type == GCONF_VALUE_LIST); g_return_if_fail (gconf_value_get_list_type (value) == GCONF_VALUE_STRING); value_list = NULL; for (node = string_list; node != NULL; node = node->next) { next_value = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (next_value, node->data); value_list = g_slist_append (value_list, next_value); } gconf_value_set_list (value, value_list); for (node = value_list; node != NULL; node = node->next) { gconf_value_free (node->data); } g_slist_free (value_list); }
static GConfValue * gconf_settings_backend_gvariant_to_gconf_value (GVariant *value) { const GVariantType *type; GConfValue *gconf_value = NULL; type = g_variant_get_type (value); if (g_variant_type_is_basic (type) && !g_variant_type_equal (type, G_VARIANT_TYPE_BASIC)) gconf_value = gconf_settings_backend_simple_gvariant_to_gconf_value (value, type); else if (g_variant_type_is_array (type)) { const GVariantType *array_type; array_type = g_variant_type_element (type); if (g_variant_type_is_basic (array_type) && !g_variant_type_equal (array_type, G_VARIANT_TYPE_BASIC)) { GConfValueType value_type; int i; GSList *list = NULL; for (i = 0; i < g_variant_n_children (value); i++) { GConfValue *l; l = gconf_settings_backend_simple_gvariant_to_gconf_value (g_variant_get_child_value (value, i), array_type); list = g_slist_prepend (list, l); } list = g_slist_reverse (list); value_type = gconf_settings_backend_simple_gvariant_type_to_gconf_value_type (array_type); gconf_value = gconf_value_new (GCONF_VALUE_LIST); gconf_value_set_list_type (gconf_value, value_type); gconf_value_set_list (gconf_value, list); g_slist_foreach (list, (GFunc) gconf_value_free, NULL); g_slist_free (list); } } else if (g_variant_type_is_tuple (type) && g_variant_type_n_items (type) == 2) { const GVariantType *first_type; const GVariantType *second_type; first_type = g_variant_type_first (type); second_type = g_variant_type_next (first_type); if (g_variant_type_is_basic (first_type) && !g_variant_type_equal (first_type, G_VARIANT_TYPE_BASIC) && g_variant_type_is_basic (second_type) && !g_variant_type_equal (second_type, G_VARIANT_TYPE_BASIC)) { GConfValue *car; GConfValue *cdr; gconf_value = gconf_value_new (GCONF_VALUE_PAIR); car = gconf_settings_backend_simple_gvariant_to_gconf_value (g_variant_get_child_value (value, 0), first_type); cdr = gconf_settings_backend_simple_gvariant_to_gconf_value (g_variant_get_child_value (value, 1), second_type); if (car) gconf_value_set_car_nocopy (gconf_value, car); if (cdr) gconf_value_set_cdr_nocopy (gconf_value, cdr); if (car == NULL || cdr == NULL) { gconf_value_free (gconf_value); gconf_value = NULL; } } } return gconf_value; }