gboolean ctx_write(PropertyContext * ctx, const gchar * schemasHome,
		   const gchar * owner, FILE * outF)

{
    if (ctx->spec->propertyFlags & MKDG_PROPERTY_FLAG_NO_BACKEND){
	return TRUE;
    }
    mkdg_xml_tags_write(outF, "schema", MKDG_XML_TAG_TYPE_BEGIN_ONLY, NULL,
			NULL);
    gchar buf[XML_BUFFER_SIZE];
    gchar *camalCasedKey=mkdg_str_dash_to_camel(ctx->spec->key);
    g_snprintf(buf, XML_BUFFER_SIZE, "/schemas%s",schemasHome);

    if (! STRING_IS_EMPTY(ctx->spec->subSection)) {
	g_strlcat(buf, "/", XML_BUFFER_SIZE);
	g_strlcat(buf, ctx->spec->subSection, XML_BUFFER_SIZE);
    } 
    g_strlcat(buf, "/", XML_BUFFER_SIZE);
    g_strlcat(buf, camalCasedKey, XML_BUFFER_SIZE);

    mkdg_xml_tags_write(outF, "key", MKDG_XML_TAG_TYPE_SHORT, NULL, buf);
    mkdg_xml_tags_write(outF, "applyto", MKDG_XML_TAG_TYPE_SHORT, NULL,
			buf + strlen("/schemas"));
    mkdg_xml_tags_write(outF, "owner", MKDG_XML_TAG_TYPE_SHORT, NULL,
			owner);
    switch (ctx->spec->valueType) {
    case G_TYPE_BOOLEAN:
	mkdg_xml_tags_write(outF, "type", MKDG_XML_TAG_TYPE_SHORT, NULL,
			    "bool");
	break;
    case G_TYPE_INT:
    case G_TYPE_UINT:
	mkdg_xml_tags_write(outF, "type", MKDG_XML_TAG_TYPE_SHORT, NULL,
			    "int");
	break;
    case G_TYPE_STRING:
	mkdg_xml_tags_write(outF, "type", MKDG_XML_TAG_TYPE_SHORT, NULL,
			    "string");
	break;
    default:
	break;
    }
    if (ctx->spec->defaultValue) {
	mkdg_xml_tags_write(outF, "default", MKDG_XML_TAG_TYPE_SHORT, NULL,
			    ctx->spec->defaultValue);
    }
    int i;
    for (i = 0; localeArray[i] != NULL; i++) {
	ctx_write_locale(ctx, outF, localeArray[i]);
    }

    setlocale(LC_ALL, NULL);
    mkdg_xml_tags_write(outF, "schema", MKDG_XML_TAG_TYPE_END_ONLY, NULL,
			NULL);
    return TRUE;
}
示例#2
0
/*============================================
 * Interface routines
 */
gchar *gconf2_backend_get_key(MkdgBackend * backend,
                              const gchar * section, const gchar * key,
                              gpointer userData)
{
    gchar *camalCasedKey =
        (gchar *) g_hash_table_lookup(camalCasedKeyTable, key);
    if (camalCasedKey == NULL) {
        camalCasedKey = mkdg_str_dash_to_camel(key);
        g_hash_table_insert(camalCasedKeyTable, (gpointer) key, camalCasedKey);
    }
    return camalCasedKey;
}