static GConfValue *gconf_value_new_g_value(GValue * value) { GConfValue *confValue; GType gType = G_VALUE_TYPE(value); switch (gType) { case G_TYPE_BOOLEAN: confValue = gconf_value_new(GCONF_VALUE_BOOL); gconf_value_set_bool(confValue, g_value_get_boolean(value)); break; case G_TYPE_INT: confValue = gconf_value_new(GCONF_VALUE_INT); gconf_value_set_int(confValue, g_value_get_int(value)); break; case G_TYPE_UINT: confValue = gconf_value_new(GCONF_VALUE_INT); gconf_value_set_int(confValue, g_value_get_uint(value)); break; case G_TYPE_STRING: confValue = gconf_value_new(GCONF_VALUE_STRING); gconf_value_set_string(confValue, g_value_get_string(value)); break; default: return NULL; } return confValue; }
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); }
int config_write (const GConfValueType data_type, const char *key, const gpointer data_value) { GConfValue *temp_value; config_open_close (CONFIG_OP_OPEN); temp_value = gconf_value_new (data_type); switch (data_type) { case GCONF_VALUE_STRING: gconf_value_set_string (temp_value, (char *) data_value); break; case GCONF_VALUE_INT: gconf_value_set_int (temp_value, (gint) data_value); break; case GCONF_VALUE_BOOL: gconf_value_set_bool (temp_value, (gboolean) data_value); break; case GCONF_VALUE_FLOAT: case GCONF_VALUE_SCHEMA: case GCONF_VALUE_LIST: case GCONF_VALUE_PAIR: case GCONF_VALUE_INVALID: { error (0, 0, _("Error writing to GConf database: Key type is not supported")); return FALSE; } } gconf_client_set (conf_client, key, temp_value, NULL); return TRUE; }
static GConfValue * action_from_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; new_value = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (new_value, gconf_enum_to_string (actions_lookup_table, gconf_value_get_int (value))); return new_value; }
static GConfValue * bell_flash_from_widget (GConfPropertyEditor *peditor, const GConfValue *value) { GConfValue *new_value; new_value = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (new_value, gconf_enum_to_string (bell_flash_enums, gconf_value_get_int (value))); return new_value; }
static GConfValue * toolbar_from_widget (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; new_value = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (new_value, gconf_enum_to_string (toolbar_style_enums, gconf_value_get_int (value))); return new_value; }
/* Helper for utils_get_value, reads int/string/float/bool/schema. */ static GConfValue * utils_get_value_helper_fundamental (DBusMessageIter *iter, GConfValueType value_type) { GConfValue *value; GConfSchema *schema; gint32 i; const gchar *s; gdouble d; gboolean b; d(g_print ("Get value (fundamental)\n")); if (value_type == GCONF_VALUE_INVALID) return NULL; value = gconf_value_new (value_type); switch (value_type) { case GCONF_VALUE_INT: dbus_message_iter_get_basic (iter, &i); gconf_value_set_int (value, i); break; case GCONF_VALUE_STRING: dbus_message_iter_get_basic (iter, &s); gconf_value_set_string (value, s); break; case GCONF_VALUE_FLOAT: dbus_message_iter_get_basic (iter, &d); gconf_value_set_float (value, d); break; case GCONF_VALUE_BOOL: dbus_message_iter_get_basic (iter, &b); gconf_value_set_bool (value, b); break; case GCONF_VALUE_SCHEMA: schema = utils_get_schema (iter); gconf_value_set_schema_nocopy (value, schema); break; default: g_assert_not_reached (); } return value; }
/* Sets a GConf value to the contents of a GtkListStore */ static gboolean list_store_binding_sync_store_to_pref (ListStoreBinding *binding) { GtkTreeModel *tree_model; GtkTreeIter iter; GSList *list; int res; GConfValue *gconf_value; tree_model = GTK_TREE_MODEL (binding->list_store); /* Build list */ list = NULL; res = gtk_tree_model_get_iter_first (tree_model, &iter); while (res) { char *string; GConfValue *tmp_value; gtk_tree_model_get (tree_model, &iter, 0, &string, -1); tmp_value = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (tmp_value, string); list = g_slist_append (list, tmp_value); res = gtk_tree_model_iter_next (tree_model, &iter); } /* Create value */ gconf_value = gconf_value_new (GCONF_VALUE_LIST); gconf_value_set_list_type (gconf_value, GCONF_VALUE_STRING); gconf_value_set_list_nocopy (gconf_value, list); /* Set */ gconf_client_set (bridge->client, binding->key, gconf_value, NULL); /* Store until change notification comes in, so that we are able * to ignore it */ binding->val_changes = g_slist_append (binding->val_changes, gconf_value); binding->sync_idle_id = 0; g_object_unref (binding->list_store); return FALSE; }
static GConfValue * _to_gconf_value (const GValue *value) { GConfValue *gv; GType type = G_VALUE_TYPE (value); switch (type) { case G_TYPE_STRING: { gv = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (gv, g_value_get_string (value)); } break; case G_TYPE_INT: { gv = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gv, g_value_get_int (value)); } break; case G_TYPE_UINT: { gv = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gv, g_value_get_uint (value)); } break; case G_TYPE_BOOLEAN: { gv = gconf_value_new (GCONF_VALUE_BOOL); gconf_value_set_bool (gv, g_value_get_boolean (value)); } break; case G_TYPE_DOUBLE: { gv = gconf_value_new (GCONF_VALUE_FLOAT); gconf_value_set_float (gv, g_value_get_double (value)); } break; case G_TYPE_FLOAT: { gv = gconf_value_new (GCONF_VALUE_FLOAT); gconf_value_set_float (gv, g_value_get_float (value)); } break; default: if (type == G_TYPE_VALUE_ARRAY) { GSList *l = NULL; GType list_type = G_TYPE_STRING; GValueArray *array = g_value_get_boxed (value); gint i; if (array && array->n_values > 0) { list_type = G_VALUE_TYPE (&(array->values[0])); } gv = gconf_value_new (GCONF_VALUE_LIST); switch (list_type) { case G_TYPE_STRING: gconf_value_set_list_type (gv, GCONF_VALUE_STRING); break; case G_TYPE_INT: case G_TYPE_UINT: gconf_value_set_list_type (gv, GCONF_VALUE_INT); break; case G_TYPE_BOOLEAN: gconf_value_set_list_type (gv, GCONF_VALUE_BOOL); break; case G_TYPE_FLOAT: case G_TYPE_DOUBLE: gconf_value_set_list_type (gv, GCONF_VALUE_FLOAT); break; default: g_assert_not_reached (); } for (i = 0; array && i < array->n_values; i++) { GConfValue *tmp; g_assert (G_VALUE_TYPE (&(array->values[i])) == list_type); tmp = _to_gconf_value (&(array->values[i])); l = g_slist_append (l, tmp); } gconf_value_set_list_nocopy (gv, l); } else g_assert_not_reached (); } return gv; }
static GConfValue *convertString(const QString &str) { GConfValue *v = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (v, str.toUtf8().data()); return v; }
static GConfValue * application_font_to_gconf (GConfPropertyEditor *peditor, GConfValue *value) { GConfValue *new_value; const char *new_font; GtkWidget *font_button; gint danger_level; font_button = GTK_WIDGET (gconf_property_editor_get_ui_control (peditor)); g_return_val_if_fail (font_button != NULL, NULL); new_value = gconf_value_new (GCONF_VALUE_STRING); new_font = gconf_value_get_string (value); if (font_dangerous (old_font)) { /* If we're already too large, we don't warn again. */ gconf_value_set_string (new_value, new_font); return new_value; } danger_level = font_dangerous (new_font); if (danger_level) { GtkWidget *warning_dialog, *apply_button; const gchar *warning_label; gchar *warning_label2; warning_label = _("Font may be too large"); if (danger_level > MAX_FONT_POINT_WITHOUT_WARNING) { warning_label2 = g_strdup_printf (ngettext ( "The font selected is %d point large, " "and may make it difficult to effectively " "use the computer. It is recommended that " "you select a size smaller than %d.", "The font selected is %d points large, " "and may make it difficult to effectively " "use the computer. It is recommended that " "you select a size smaller than %d.", danger_level), danger_level, MAX_FONT_POINT_WITHOUT_WARNING); } else { warning_label2 = g_strdup_printf (ngettext ( "The font selected is %d point large, " "and may make it difficult to effectively " "use the computer. It is recommended that " "you select a smaller sized font.", "The font selected is %d points large, " "and may make it difficult to effectively " "use the computer. It is recommended that " "you select a smaller sized font.", danger_level), danger_level); } warning_dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, warning_label); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (warning_dialog), warning_label2); gtk_dialog_add_button (GTK_DIALOG (warning_dialog), _("Use previous font"), GTK_RESPONSE_CLOSE); apply_button = gtk_button_new_with_label (_("Use selected font")); gtk_button_set_image (GTK_BUTTON (apply_button), gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON)); gtk_dialog_add_action_widget (GTK_DIALOG (warning_dialog), apply_button, GTK_RESPONSE_APPLY); GTK_WIDGET_SET_FLAGS (apply_button, GTK_CAN_DEFAULT); gtk_widget_show (apply_button); gtk_dialog_set_default_response (GTK_DIALOG (warning_dialog), GTK_RESPONSE_CLOSE); g_free (warning_label2); if (gtk_dialog_run (GTK_DIALOG (warning_dialog)) == GTK_RESPONSE_APPLY) { gconf_value_set_string (new_value, new_font); } else { gconf_value_set_string (new_value, old_font); gtk_font_button_set_font_name (GTK_FONT_BUTTON (font_button), old_font); } gtk_widget_destroy (warning_dialog); } else { gconf_value_set_string (new_value, new_font); } return new_value; }
/* Syncs an object property to GConf */ static void prop_binding_sync_prop_to_pref (PropBinding *binding) { GValue value; GConfValue *gconf_value; memset (&value, 0, sizeof (GValue)); g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (binding->prop)); g_object_get_property (binding->object, binding->prop->name, &value); switch (value.g_type) { case G_TYPE_STRING: gconf_value = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (gconf_value, g_value_get_string (&value)); break; case G_TYPE_INT: gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_int (&value)); break; case G_TYPE_UINT: gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_uint (&value)); break; case G_TYPE_LONG: gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_long (&value)); break; case G_TYPE_ULONG: gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_ulong (&value)); break; case G_TYPE_INT64: gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_int64 (&value)); break; case G_TYPE_UINT64: gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_uint64 (&value)); break; case G_TYPE_CHAR: gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_char (&value)); break; case G_TYPE_UCHAR: gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_uchar (&value)); break; case G_TYPE_ENUM: gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_enum (&value)); break; case G_TYPE_BOOLEAN: gconf_value = gconf_value_new (GCONF_VALUE_BOOL); gconf_value_set_bool (gconf_value, g_value_get_boolean (&value)); break; case G_TYPE_DOUBLE: gconf_value = gconf_value_new (GCONF_VALUE_FLOAT); #ifdef HAVE_CORBA_GCONF /* FIXME we cast to a float explicitly as CORBA GConf * uses doubles in its API, but treats them as floats * when transporting them over CORBA. See #322837 */ gconf_value_set_float (gconf_value, (float) g_value_get_double (&value)); #else gconf_value_set_float (gconf_value, g_value_get_double (&value)); #endif break; case G_TYPE_FLOAT: gconf_value = gconf_value_new (GCONF_VALUE_FLOAT); gconf_value_set_float (gconf_value, g_value_get_float (&value)); break; default: if (g_type_is_a (value.g_type, G_TYPE_ENUM)) { gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, g_value_get_enum (&value)); } else { g_warning ("prop_binding_sync_prop_to_pref: " "Unhandled value type '%s'.\n", g_type_name (value.g_type)); goto done; } break; } /* Set to GConf */ gconf_client_set (bridge->client, binding->key, gconf_value, NULL); /* Store until change notification comes in, so that we are able * to ignore it */ binding->val_changes = g_slist_append (binding->val_changes, gconf_value); done: g_value_unset (&value); }
static GConfValue * gconf_settings_backend_simple_gvariant_to_gconf_value (GVariant *value, const GVariantType *type) { GConfValue *gconf_value = NULL; if (g_variant_type_equal (type, G_VARIANT_TYPE_BOOLEAN)) { gconf_value = gconf_value_new (GCONF_VALUE_BOOL); gconf_value_set_bool (gconf_value, g_variant_get_boolean (value)); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_BYTE)) { guchar i = g_variant_get_byte (value); gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, i); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_INT16)) { gint16 i = g_variant_get_int16 (value); gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, i); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_UINT16)) { guint16 i = g_variant_get_uint16 (value); if (i > G_MAXINT) return NULL; gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, i); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_INT32)) { gint32 i = g_variant_get_int32 (value); gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, i); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_UINT32)) { guint32 i = g_variant_get_uint32 (value); if (i > G_MAXINT) return NULL; gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, i); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_INT64)) { gint64 i = g_variant_get_int64 (value); if (i < G_MININT || i > G_MAXINT) return NULL; gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, i); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_UINT64)) { guint64 i = g_variant_get_uint64 (value); if (i > G_MAXINT) return NULL; gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, i); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_HANDLE)) { guint32 i = g_variant_get_handle (value); if (i > G_MAXINT) return NULL; gconf_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (gconf_value, i); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_DOUBLE)) { gconf_value = gconf_value_new (GCONF_VALUE_FLOAT); gconf_value_set_float (gconf_value, g_variant_get_double (value)); } else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING) || g_variant_type_equal (type, G_VARIANT_TYPE_OBJECT_PATH) || g_variant_type_equal (type, G_VARIANT_TYPE_SIGNATURE)) { gconf_value = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (gconf_value, g_variant_get_string (value, NULL)); } return gconf_value; }
/* Helper for utils_get_value, reads a list. The "list" is a struct with the * list type and an array with the values directly in it. */ static GConfValue * utils_get_value_helper_list (DBusMessageIter *iter) { DBusMessageIter struct_iter; DBusMessageIter array_iter; GConfValue *value; gint32 list_type; GSList *list; GConfValue *child_value; d(g_print ("Get value (list)\n")); value = gconf_value_new (GCONF_VALUE_LIST); dbus_message_iter_recurse (iter, &struct_iter); /* Get the list type. */ dbus_message_iter_get_basic (&struct_iter, &list_type); gconf_value_set_list_type (value, list_type); /* Get the array. */ dbus_message_iter_next (&struct_iter); dbus_message_iter_recurse (&struct_iter, &array_iter); /* And the values from the array. */ list = NULL; switch (list_type) { case GCONF_VALUE_STRING: while (dbus_message_iter_get_arg_type (&array_iter) == DBUS_TYPE_STRING) { const gchar *str; dbus_message_iter_get_basic (&array_iter, &str); child_value = gconf_value_new (GCONF_VALUE_STRING); gconf_value_set_string (child_value, str); list = g_slist_prepend (list, child_value); dbus_message_iter_next (&array_iter); } break; case GCONF_VALUE_INT: while (dbus_message_iter_get_arg_type (&array_iter) == DBUS_TYPE_INT32) { gint32 i; dbus_message_iter_get_basic (&array_iter, &i); child_value = gconf_value_new (GCONF_VALUE_INT); gconf_value_set_int (child_value, i); list = g_slist_prepend (list, child_value); dbus_message_iter_next (&array_iter); } break; case GCONF_VALUE_FLOAT: while (dbus_message_iter_get_arg_type (&array_iter) == DBUS_TYPE_DOUBLE) { gdouble d; dbus_message_iter_get_basic (&array_iter, &d); child_value = gconf_value_new (GCONF_VALUE_FLOAT); gconf_value_set_float (child_value, d); list = g_slist_prepend (list, child_value); dbus_message_iter_next (&array_iter); } break; case GCONF_VALUE_BOOL: while (dbus_message_iter_get_arg_type (&array_iter) == DBUS_TYPE_BOOLEAN) { gboolean b; dbus_message_iter_get_basic (&array_iter, &b); child_value = gconf_value_new (GCONF_VALUE_BOOL); gconf_value_set_bool (child_value, b); list = g_slist_prepend (list, child_value); dbus_message_iter_next (&array_iter); } break; case GCONF_VALUE_SCHEMA: while (dbus_message_iter_get_arg_type (&array_iter) == DBUS_TYPE_STRUCT) { child_value = utils_get_schema_value (&array_iter); list = g_slist_prepend (list, child_value); dbus_message_iter_next (&array_iter); } break; default: g_assert_not_reached (); } list = g_slist_reverse (list); gconf_value_set_list_nocopy (value, list); return value; }
/* this actually works on any node, not just <entry>, such as the <car> and <cdr> nodes and the <li> nodes and the <default> node */ static GConfValue* node_extract_value(xmlNodePtr node, const gchar** locales, GError** err) { GConfValue* value = NULL; gchar* type_str; GConfValueType type = GCONF_VALUE_INVALID; const gchar* default_locales[] = { "C", NULL }; if (locales == NULL) locales = default_locales; type_str = my_xmlGetProp(node, "type"); if (type_str == NULL) { gconf_set_error(err, GCONF_ERROR_PARSE_ERROR, _("No \"type\" attribute for <%s> node"), (node->name ? (char*)node->name : "(nil)")); return NULL; } type = gconf_value_type_from_string(type_str); xmlFree(type_str); switch (type) { case GCONF_VALUE_INVALID: { gconf_set_error(err, GCONF_ERROR_PARSE_ERROR, _("A node has unknown \"type\" attribute `%s', ignoring"), type_str); return NULL; } break; case GCONF_VALUE_INT: case GCONF_VALUE_BOOL: case GCONF_VALUE_FLOAT: { gchar* value_str; value_str = my_xmlGetProp(node, "value"); if (value_str == NULL) { gconf_set_error(err, GCONF_ERROR_PARSE_ERROR, _("No \"value\" attribute for node")); return NULL; } value = gconf_value_new_from_string(type, value_str, err); xmlFree(value_str); g_return_val_if_fail( (value != NULL) || (err == NULL) || (*err != NULL), NULL ); return value; } break; case GCONF_VALUE_STRING: { xmlNodePtr iter; iter = node->xmlChildrenNode; while (iter != NULL) { if (iter->type == XML_ELEMENT_NODE) { GConfValue* v = NULL; if (strcmp((char *)iter->name, "stringvalue") == 0) { gchar* s; s = (gchar *)xmlNodeGetContent(iter); v = gconf_value_new(GCONF_VALUE_STRING); /* strdup() caused purely by g_free()/free() difference */ gconf_value_set_string(v, s ? s : ""); if (s) xmlFree(s); return v; } else { /* What the hell is this? */ gconf_log(GCL_WARNING, _("Didn't understand XML node <%s> inside an XML list node"), iter->name ? iter->name : (guchar*)"???"); } } iter = iter->next; } return NULL; } break; case GCONF_VALUE_SCHEMA: return schema_node_extract_value(node, locales); break; case GCONF_VALUE_LIST: { xmlNodePtr iter; GSList* values = NULL; GConfValueType list_type = GCONF_VALUE_INVALID; { gchar* s; s = my_xmlGetProp(node, "ltype"); if (s != NULL) { list_type = gconf_value_type_from_string(s); xmlFree(s); } } switch (list_type) { case GCONF_VALUE_INVALID: case GCONF_VALUE_LIST: case GCONF_VALUE_PAIR: gconf_set_error(err, GCONF_ERROR_PARSE_ERROR, _("Invalid type (list, pair, or unknown) in a list node")); return NULL; default: break; } iter = node->xmlChildrenNode; while (iter != NULL) { if (iter->type == XML_ELEMENT_NODE) { GConfValue* v = NULL; if (strcmp((char*)iter->name, "li") == 0) { v = node_extract_value(iter, locales, err); if (v == NULL) { if (err && *err) { gconf_log(GCL_WARNING, _("Bad XML node: %s"), (*err)->message); /* avoid pile-ups */ g_clear_error(err); } } else if (v->type != list_type) { gconf_log(GCL_WARNING, _("List contains a badly-typed node (%s, should be %s)"), gconf_value_type_to_string(v->type), gconf_value_type_to_string(list_type)); gconf_value_free(v); v = NULL; } } else { /* What the hell is this? */ gconf_log(GCL_WARNING, _("Didn't understand XML node <%s> inside an XML list node"), iter->name ? iter->name : (guchar*)"???"); } if (v != NULL) values = g_slist_prepend(values, v); } iter = iter->next; } /* put them in order, set the value */ values = g_slist_reverse(values); value = gconf_value_new(GCONF_VALUE_LIST); gconf_value_set_list_type(value, list_type); gconf_value_set_list_nocopy(value, values); return value; } break; case GCONF_VALUE_PAIR: { GConfValue* car = NULL; GConfValue* cdr = NULL; xmlNodePtr iter; iter = node->xmlChildrenNode; while (iter != NULL) { if (iter->type == XML_ELEMENT_NODE) { if (car == NULL && strcmp((char *)iter->name, "car") == 0) { car = node_extract_value(iter, locales, err); if (car == NULL) { if (err && *err) { gconf_log(GCL_WARNING, _("Ignoring bad car from XML pair: %s"), (*err)->message); /* prevent pile-ups */ g_clear_error(err); } } else if (car->type == GCONF_VALUE_LIST || car->type == GCONF_VALUE_PAIR) { gconf_log(GCL_WARNING, _("parsing XML file: lists and pairs may not be placed inside a pair")); gconf_value_free(car); car = NULL; } } else if (cdr == NULL && strcmp((char *)iter->name, "cdr") == 0) { cdr = node_extract_value(iter, locales, err); if (cdr == NULL) { if (err && *err) { gconf_log(GCL_WARNING, _("Ignoring bad cdr from XML pair: %s"), (*err)->message); /* avoid pile-ups */ g_clear_error(err); } } else if (cdr->type == GCONF_VALUE_LIST || cdr->type == GCONF_VALUE_PAIR) { gconf_log(GCL_WARNING, _("parsing XML file: lists and pairs may not be placed inside a pair")); gconf_value_free(cdr); cdr = NULL; } } else { /* What the hell is this? */ gconf_log(GCL_WARNING, _("Didn't understand XML node <%s> inside an XML pair node"), iter->name ? (gchar*)iter->name : "???"); } } iter = iter->next; } /* Return the pair if we got both halves */ if (car && cdr) { value = gconf_value_new(GCONF_VALUE_PAIR); gconf_value_set_car_nocopy(value, car); gconf_value_set_cdr_nocopy(value, cdr); return value; } else { gconf_log(GCL_WARNING, _("Didn't find car and cdr for XML pair node")); if (car) { g_assert(cdr == NULL); gconf_value_free(car); gconf_set_error(err, GCONF_ERROR_PARSE_ERROR, _("Missing cdr from pair of values in XML file")); } else if (cdr) { g_assert(car == NULL); gconf_value_free(cdr); gconf_set_error(err, GCONF_ERROR_PARSE_ERROR, _("Missing car from pair of values in XML file")); } else { gconf_set_error(err, GCONF_ERROR_PARSE_ERROR, _("Missing both car and cdr values from pair in XML file")); } return NULL; } } break; default: g_assert_not_reached(); return NULL; break; } }