95
gconf_engine_unset(conf, *keyp, &err);
124
g_assert (err == NULL);
126
gconf_engine_unset (conf, *keyp, &err);
99
fprintf(stderr, "unset of `%s' failed: %s\n", *keyp, err->message);
130
fprintf (stderr, "unset of `%s' failed: %s\n", *keyp, err->message);
108
val = gconf_engine_get (conf, *keyp, &err);
140
val = gconf_engine_get_without_default (conf, *keyp, &err);
144
fprintf (stderr, "gconf_engine_get_without_default on key %s failed: %s\n", *keyp, err->message);
112
valstr = gconf_value_to_string(val);
151
valstr = gconf_value_to_string (val);
114
valstr = g_strdup("(none)");
153
valstr = g_strdup ("(none)");
116
check(val == NULL, "unsetting a previously-set value `%s' the value `%s' existed", *keyp, valstr);
155
check (val == NULL, "unsetting a previously-set value `%s' the value `%s' existed", *keyp, valstr);
245
284
GError* err = NULL;
247
if (!gconf_engine_set_schema(conf, *keyp, schema, &err))
286
if (!gconf_engine_set_schema (conf, *keyp, schema, &err))
249
fprintf(stderr, "Failed to set key `%s' to schema: %s\n",
288
fprintf (stderr, "Failed to set key `%s' to schema: %s\n",
250
289
*keyp, err->message);
256
295
GConfSchema* gotten;
258
gotten = gconf_engine_get_schema(conf, *keyp, &err);
298
val = gconf_engine_get_with_locale (conf, *keyp, gconf_schema_get_locale (schema), &err);
262
check(gotten == NULL, "NULL not returned though there was an error");
302
check (val == NULL, "NULL not returned though there was an error");
264
fprintf(stderr, "Failed to get key `%s': %s\n",
265
*keyp, err->message);
304
fprintf (stderr, "Failed to get key `%s': %s\n",
305
*keyp, err->message);
266
306
g_error_free(err);
271
check (gconf_schema_get_type(schema) == gconf_schema_get_type(gotten),
311
check (val != NULL, "Did not get a schema back after setting it");
313
check (val->type == GCONF_VALUE_SCHEMA, "Got type %s back instead of schema",
314
gconf_value_type_to_string (val->type));
316
gotten = gconf_value_get_schema (val);
318
check (gconf_schema_get_type (schema) == gconf_schema_get_type (gotten),
272
319
"schema set/get pair: type `%s' set, `%s' got",
273
gconf_value_type_to_string(gconf_schema_get_type(schema)),
274
gconf_value_type_to_string(gconf_schema_get_type(gotten)));
320
gconf_value_type_to_string (gconf_schema_get_type (schema)),
321
gconf_value_type_to_string (gconf_schema_get_type (gotten)));
277
323
/* If we set the schema for the current locale be sure we get it back */
278
if (null_safe_strcmp(gconf_current_locale(), gconf_schema_get_locale(schema)) == 0)
324
if (null_safe_strcmp (gconf_current_locale (), gconf_schema_get_locale (schema)) == 0)
280
326
check (null_safe_strcmp(gconf_current_locale(), gconf_schema_get_locale(gotten)) == 0,
281
327
"schema set/get pair: locale `%s' set, `%s' got",
282
328
gconf_current_locale(),
283
NULL_SAFE(gconf_schema_get_locale(gotten)));
329
NULL_SAFE (gconf_schema_get_locale (gotten)));
286
check (null_safe_strcmp(gconf_schema_get_short_desc(schema), gconf_schema_get_short_desc(gotten)) == 0,
332
check (null_safe_strcmp (gconf_schema_get_short_desc (schema), gconf_schema_get_short_desc (gotten)) == 0,
287
333
"schema set/get pair: short_desc `%s' set, `%s' got",
288
NULL_SAFE(gconf_schema_get_short_desc(schema)),
289
NULL_SAFE(gconf_schema_get_short_desc(gotten)));
334
NULL_SAFE (gconf_schema_get_short_desc (schema)),
335
NULL_SAFE (gconf_schema_get_short_desc (gotten)));
291
check (null_safe_strcmp(gconf_schema_get_long_desc(schema), gconf_schema_get_long_desc(gotten)) == 0,
337
check (null_safe_strcmp (gconf_schema_get_long_desc (schema), gconf_schema_get_long_desc (gotten)) == 0,
292
338
"schema set/get pair: long_desc `%s' set, `%s' got",
293
NULL_SAFE(gconf_schema_get_long_desc(schema)),
294
NULL_SAFE(gconf_schema_get_long_desc(gotten)));
339
NULL_SAFE (gconf_schema_get_long_desc (schema)),
340
NULL_SAFE (gconf_schema_get_long_desc (gotten)));
296
check (null_safe_strcmp(gconf_schema_get_owner(schema), gconf_schema_get_owner(gotten)) == 0,
342
check (null_safe_strcmp (gconf_schema_get_owner(schema), gconf_schema_get_owner(gotten)) == 0,
297
343
"schema set/get pair: owner `%s' set, `%s' got",
298
NULL_SAFE(gconf_schema_get_owner(schema)),
299
NULL_SAFE(gconf_schema_get_owner(gotten)));
344
NULL_SAFE (gconf_schema_get_owner (schema)),
345
NULL_SAFE (gconf_schema_get_owner (gotten)));
302
348
GConfValue* set_default;
303
349
GConfValue* got_default;
305
set_default = gconf_schema_get_default_value(schema);
306
got_default = gconf_schema_get_default_value(gotten);
351
set_default = gconf_schema_get_default_value (schema);
352
got_default = gconf_schema_get_default_value (gotten);
308
354
if (set_default && got_default)
310
check(set_default->type == GCONF_VALUE_INT,
356
check (set_default->type == GCONF_VALUE_INT,
311
357
"set default type is INT");
313
check(set_default->type == got_default->type,
314
"schema set/get pair: default value type `%s' set, `%s' got",
315
gconf_value_type_to_string(set_default->type),
316
gconf_value_type_to_string(got_default->type));
318
check(set_default->type == got_default->type,
319
"schema set/get pair: default value type `%s' set, `%s' got",
320
gconf_value_type_to_string(set_default->type),
321
gconf_value_type_to_string(got_default->type));
323
check(gconf_value_get_int(set_default) == gconf_value_get_int(got_default),
324
"schema set/get pair: default value (int) `%d' set, `%d' got",
325
gconf_value_get_int(set_default), gconf_value_get_int(got_default));
359
check (set_default->type == got_default->type,
360
"schema set/get pair: default value type `%s' set, `%s' got",
361
gconf_value_type_to_string(set_default->type),
362
gconf_value_type_to_string(got_default->type));
364
check (set_default->type == got_default->type,
365
"schema set/get pair: default value type `%s' set, `%s' got",
366
gconf_value_type_to_string(set_default->type),
367
gconf_value_type_to_string(got_default->type));
369
check (gconf_value_get_int(set_default) == gconf_value_get_int(got_default),
370
"schema set/get pair: default value (int) `%d' set, `%d' got",
371
gconf_value_get_int(set_default), gconf_value_get_int(got_default));
365
411
if (*localep == NULL)
366
412
localep = locales;
368
schema = gconf_schema_new();
370
gconf_schema_set_type(schema, GCONF_VALUE_INT);
371
gconf_schema_set_locale(schema, *localep);
372
short_desc = g_strdup_printf("Schema for key `%s' storing value %d",
374
gconf_schema_set_short_desc(schema, short_desc);
376
long_desc = g_strdup_printf("Long description for schema with short description `%s' is really really long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long "
414
schema = gconf_schema_new ();
416
gconf_schema_set_type (schema, GCONF_VALUE_INT);
417
gconf_schema_set_locale (schema, *localep);
418
short_desc = g_strdup_printf ("Schema for key `%s' storing value %d",
420
gconf_schema_set_short_desc (schema, short_desc);
422
long_desc = g_strdup_printf ("Long description for schema with short description `%s' is really really long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long "
377
423
"UTF-8: German (Deutsch SĆ¼d) GrĆ¼Ć Gott Greek (ĪĪ»Ī»Ī·Ī½Ī¹ĪŗĪ¬) ĪĪµĪ¹Ī¬ ĻĪ±Ļ Hebrew(ש×××) Hebrew punctuation(\xd6\xbfש\xd6\xbb\xd6\xbc\xd6\xbb\xd6\xbf×\xd6\xbc×\xd6\xbc\xd6\xbb\xd6\xbb\xd6\xbf×\xd6\xbc\xd6\xbb\xd6\xbf) Japanese (ę„ę¬čŖ) Thai (ąøŖąø§ąø±ąøŖąøąøµąøąø£ąø±ąø) Thai wrong spelling (ąøąø³ąøą¹ąøą¹ąøąøąø·ą¹ąøŖąø°ąøąøąøąø“ąø ąøąø±ąø±ą¹ąø±ąø±ą¹ąøą¹ąøąø°)\n", short_desc);
379
gconf_schema_set_long_desc(schema, long_desc);
381
gconf_schema_set_owner(schema, "testschemas");
383
default_value = gconf_value_new(GCONF_VALUE_INT);
384
gconf_value_set_int(default_value, default_value_int);
386
gconf_schema_set_default_value_nocopy(schema, default_value);
388
check(gconf_value_get_int(gconf_schema_get_default_value(schema)) == default_value_int,
389
"Properly stored default int value in the schema");
391
check_one_schema(conf, keyp, schema);
425
gconf_schema_set_long_desc (schema, long_desc);
427
gconf_schema_set_owner (schema, "testschemas");
429
default_value = gconf_value_new (GCONF_VALUE_INT);
430
gconf_value_set_int (default_value, default_value_int);
432
gconf_schema_set_default_value_nocopy (schema, default_value);
434
check (gconf_value_get_int (gconf_schema_get_default_value (schema)) == default_value_int,
435
"Properly stored default int value in the schema");
437
check_one_schema (conf, keyp, schema);
393
439
gconf_schema_free(schema);
394
440
g_free(long_desc);
395
441
g_free(short_desc);
432
478
check_unset(conf);
484
SCHEMA_INFO_SHORT_DOCS,
485
SCHEMA_INFO_LONG_DOCS,
486
SCHEMA_INFO_SCHEMA_NAME
490
get_schema_info (GConfEngine *conf, const gchar *key, int info)
499
entry = gconf_engine_get_entry (conf, key, NULL, TRUE, &err);
505
s = gconf_entry_get_schema_name (entry);
511
else if (info == SCHEMA_INFO_SCHEMA_NAME)
513
retval = g_strdup (s);
521
val = gconf_engine_get (conf, s, &err);
523
if (val != NULL && val->type == GCONF_VALUE_SCHEMA)
527
schema = gconf_value_get_schema (val);
531
if (info == SCHEMA_INFO_SHORT_DOCS)
532
retval = g_strdup (gconf_schema_get_short_desc (schema));
533
else if (info == SCHEMA_INFO_LONG_DOCS)
534
retval = g_strdup (gconf_schema_get_long_desc (schema));
537
else if (err != NULL)
539
fprintf (stderr, "Error getting schema at '%s': %s\n",
547
fprintf (stderr, "No schema stored at '%s'\n",
550
fprintf (stderr, "Value at '%s' is not a schema\n",
557
gconf_value_free (val);
560
gconf_entry_free (entry);
566
fprintf(stderr, "No value set for `%s'\n", key);
570
fprintf(stderr, "Failed to get value for `%s': %s\n",
436
581
check_schema_use(GConfEngine * conf)
452
597
gconf_value_set_string(value, schema_value);
453
598
gconf_schema_set_default_value(schema, value);
455
if (gconf_engine_set_schema(conf, schema_key, schema, &err))
600
if (!gconf_engine_set_schema(conf, schema_key, schema, &err))
459
fprintf(stderr, "gconf_engine_set_schema -> %s\n", err->message);
602
fprintf(stderr, "gconf_engine_set_schema -> %s\n", err->message);
468
if (gconf_engine_associate_schema(conf, *keyp, schema_key, &err))
610
if (!gconf_engine_associate_schema(conf, *keyp, schema_key, &err))
472
fprintf(stderr, "gconf_engine_associate_schema -> %s\n", err->message);
612
fprintf(stderr, "gconf_engine_associate_schema -> %s\n", err->message);
618
/* Make sure we can get schema name */
619
s = get_schema_info (conf, *keyp, SCHEMA_INFO_SCHEMA_NAME);
622
fprintf (stderr, "ERROR: Failed to get initial schema name\n");
625
else if (strcmp (s, schema_key) != 0)
627
fprintf (stderr, "ERROR: got wrong schema name '%s'\n", schema_key);
487
gconf_engine_unset(conf, *keyp, &err);
642
g_assert (err == NULL);
643
gconf_engine_unset (conf, *keyp, &err);
647
fprintf(stderr, "gconf_engine_unset -> %s\n", err->message);
488
653
s = gconf_engine_get_string(conf, *keyp, &err);
657
fprintf(stderr, "gconf_engine_get_string -> %s\n", err->message);
491
665
if (strcmp(s, schema_value) != 0)
493
667
fprintf(stderr, "ERROR: Failed to get schema value (got '%s', not '%s')\n", s, schema_value);
502
679
fprintf(stderr, "ERROR: Failed to get a value when expecting schema value\n");
505
683
/* associate_schema should accept NULL to unset schemas */
506
gconf_engine_associate_schema(conf, *keyp, "/bogus-nonschema", &err);
684
if (!gconf_engine_associate_schema (conf, *keyp, "/bogus-nonschema", &err))
686
fprintf(stderr, "gconf_engine_associate_schema -> %s\n", err->message);
692
/* Make sure we can get schema name */
693
s = get_schema_info (conf, *keyp, SCHEMA_INFO_SCHEMA_NAME);
696
fprintf (stderr, "ERROR: Failed to get bogus schema name\n");
699
else if (strcmp (s, "/bogus-nonschema") != 0)
701
fprintf (stderr, "ERROR: got wrong schema name '%s'\n", schema_key);
507
707
s = gconf_engine_get_string(conf, *keyp, &err);
711
fprintf(stderr, "gconf_engine_get_string -> %s\n", err->message);
510
719
fprintf(stderr, "Failed to disassociate schema, found '%s'\n", s);
513
724
gconf_engine_set_string(conf, *keyp, non_schema_value, &err);
727
fprintf(stderr, "gconf_engine_set_string -> %s\n", err->message);
514
733
s = gconf_engine_get_string(conf, *keyp, &err);
517
737
if (strcmp(s, non_schema_value) != 0)
519
739
fprintf(stderr, "ERROR: Failed to get non-schema value (got '%s', not '%s')\n", s, non_schema_value);
528
751
fprintf(stderr, "ERROR: Failed to get a value when expecting non-schema value\n");
755
fprintf(stderr, "gconf_engine_get_string -> %s\n", err->message);
763
/* Make sure we can still get schema name when we have a value set */
764
s = get_schema_info (conf, *keyp, SCHEMA_INFO_SCHEMA_NAME);
767
fprintf (stderr, "ERROR: Failed to get schema name when a value was set in the database\n");
770
else if (strcmp (s, "/bogus-nonschema") != 0)
772
fprintf (stderr, "ERROR: got wrong schema name '%s'\n", schema_key);