static GConfSchema* gconf_dialog_safely_get_schema (GConfDialog* self, GConfEntry* entry) { GConfSchema* result = NULL; GError * _inner_error_; const char* schema_name; GConfSchema* rt; GConfSchema* _tmp3_; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (entry != NULL, NULL); _inner_error_ = NULL; schema_name = gconf_entry_get_schema_name (entry); rt = NULL; if (schema_name != NULL) { { GConfSchema* _tmp0_; GConfSchema* _tmp2_; GConfSchema* _tmp1_; _tmp0_ = gconf_client_get_schema (self->priv->_default_client, schema_name, &_inner_error_); if (_inner_error_ != NULL) { goto __catch24_g_error; } rt = (_tmp2_ = gconf_schema_copy (_tmp1_ = _tmp0_), _gconf_schema_free0 (rt), _tmp2_); _gconf_schema_free0 (_tmp1_); result = rt; return result; } goto __finally24; __catch24_g_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; { _g_error_free0 (e); } } __finally24: if (_inner_error_ != NULL) { _gconf_schema_free0 (rt); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } g_critical ("gtkextra-gconfdialog.vala:161: schema not found for entry %s", gconf_entry_get_key (entry)); rt = (_tmp3_ = gconf_schema_new (), _gconf_schema_free0 (rt), _tmp3_); gconf_schema_set_short_desc (rt, gconf_entry_get_key (entry)); gconf_schema_set_long_desc (rt, "This key lacks a schema"); gconf_schema_set_type (rt, GCONF_VALUE_STRING); result = rt; return result; }
static GConfSchema * utils_get_schema (DBusMessageIter *main_iter) { DBusMessageIter struct_iter; gint32 type, list_type, car_type, cdr_type; const gchar *locale, *short_desc, *long_desc, *owner; const gchar *encoded; GConfSchema *schema; GConfValue *default_value; g_assert (dbus_message_iter_get_arg_type (main_iter) == DBUS_TYPE_STRUCT); dbus_message_iter_recurse (main_iter, &struct_iter); dbus_message_iter_get_basic (&struct_iter, &type); dbus_message_iter_next (&struct_iter); dbus_message_iter_get_basic (&struct_iter, &list_type); dbus_message_iter_next (&struct_iter); dbus_message_iter_get_basic (&struct_iter, &car_type); dbus_message_iter_next (&struct_iter); dbus_message_iter_get_basic (&struct_iter, &cdr_type); dbus_message_iter_next (&struct_iter); locale = utils_get_optional_string (&struct_iter); dbus_message_iter_next (&struct_iter); short_desc = utils_get_optional_string (&struct_iter); dbus_message_iter_next (&struct_iter); long_desc = utils_get_optional_string (&struct_iter); dbus_message_iter_next (&struct_iter); owner = utils_get_optional_string (&struct_iter); dbus_message_iter_next (&struct_iter); dbus_message_iter_get_basic (&struct_iter, &encoded); schema = gconf_schema_new (); gconf_schema_set_type (schema, type); gconf_schema_set_list_type (schema, list_type); gconf_schema_set_car_type (schema, car_type); gconf_schema_set_cdr_type (schema, cdr_type); if (locale) gconf_schema_set_locale (schema, locale); if (short_desc) gconf_schema_set_short_desc (schema, short_desc); if (long_desc) gconf_schema_set_long_desc (schema, long_desc); if (owner) gconf_schema_set_owner (schema, owner); if (*encoded != '\0') { default_value = gconf_value_decode (encoded); if (default_value) gconf_schema_set_default_value_nocopy (schema, default_value); } return schema; }
static GConfValue* schema_node_extract_value(xmlNodePtr node, const gchar** locales) { GConfValue* value = NULL; gchar* owner_str; gchar* stype_str; gchar* list_type_str; gchar* car_type_str; gchar* cdr_type_str; GConfSchema* sc; xmlNodePtr iter; guint i; xmlNodePtr* localized_nodes; xmlNodePtr best = NULL; /* owner, type are for all locales; default value, descriptions are per-locale */ owner_str = my_xmlGetProp(node, "owner"); stype_str = my_xmlGetProp(node, "stype"); list_type_str = my_xmlGetProp(node, "list_type"); car_type_str = my_xmlGetProp(node, "car_type"); cdr_type_str = my_xmlGetProp(node, "cdr_type"); sc = gconf_schema_new(); if (owner_str) { gconf_schema_set_owner(sc, owner_str); xmlFree(owner_str); } if (stype_str) { GConfValueType stype; stype = gconf_value_type_from_string(stype_str); gconf_schema_set_type(sc, stype); xmlFree(stype_str); } if (list_type_str) { GConfValueType type; type = gconf_value_type_from_string(list_type_str); gconf_schema_set_list_type(sc, type); xmlFree(list_type_str); } if (car_type_str) { GConfValueType type; type = gconf_value_type_from_string(car_type_str); gconf_schema_set_car_type(sc, type); xmlFree(car_type_str); } if (cdr_type_str) { GConfValueType type; type = gconf_value_type_from_string(cdr_type_str); gconf_schema_set_cdr_type(sc, type); xmlFree(cdr_type_str); } if (locales != NULL && locales[0]) { /* count the number of possible locales */ int n_locales; n_locales = 0; while (locales[n_locales]) ++n_locales; localized_nodes = g_new0(xmlNodePtr, n_locales); /* Find the node for each possible locale */ iter = node->xmlChildrenNode; while (iter != NULL) { if (iter->type == XML_ELEMENT_NODE && strcmp((char *)iter->name, "local_schema") == 0) { char* locale_name; locale_name = my_xmlGetProp(iter, "locale"); if (locale_name != NULL) { i = 0; while (locales[i]) { if (strcmp(locales[i], locale_name) == 0) { localized_nodes[i] = iter; break; } ++i; } xmlFree(locale_name); /* Quit as soon as we have the best possible locale */ if (localized_nodes[0] != NULL) break; } } iter = iter->next; } /* See which is the best locale we managed to load, they are in order of preference. */ i = 0; best = localized_nodes[i]; while (best == NULL && i < n_locales) { best = localized_nodes[i]; ++i; } g_free(localized_nodes); } /* If no locale matched, try picking the the null localization, * and then try picking the first node */ if (best == NULL) best = find_schema_subnode_by_locale (node, NULL); if (best == NULL) { best = node->xmlChildrenNode; while (best && best->type != XML_ELEMENT_NODE) best = best->next; } /* Extract info from the best locale node */ if (best != NULL) schema_subnode_extract_data(best, sc); /* Create a GConfValue with this schema and return it */ value = gconf_value_new(GCONF_VALUE_SCHEMA); gconf_value_set_schema_nocopy(value, sc); return value; }