{
gchar **keys;
- keys = g_settings_list_keys (global_settings);
+ keys = g_settings_schema_list_keys (global_schema);
output_list (keys);
g_strfreev (keys);
}
enumerate (GSettings *settings)
{
gchar **keys;
- gchar *schema;
+ GSettingsSchema *schema;
gint i;
- g_object_get (settings, "schema-id", &schema, NULL);
+ g_object_get (settings, "settings-schema", &schema, NULL);
- keys = g_settings_list_keys (settings);
+ keys = g_settings_schema_list_keys (schema);
for (i = 0; keys[i]; i++)
{
GVariant *value;
value = g_settings_get_value (settings, keys[i]);
printed = g_variant_print (value, TRUE);
- g_print ("%s %s %s\n", schema, keys[i], printed);
+ g_print ("%s %s %s\n", g_settings_schema_get_id (schema), keys[i], printed);
g_variant_unref (value);
g_free (printed);
}
- g_free (schema);
+ g_settings_schema_unref (schema);
g_strfreev (keys);
}
static void
reset_all_keys (GSettings *settings)
{
+ GSettingsSchema *schema;
gchar **keys;
gint i;
- keys = g_settings_list_keys (settings);
+ g_object_get (settings, "settings-schema", &schema, NULL);
+
+ keys = g_settings_schema_list_keys (schema);
for (i = 0; keys[i]; i++)
{
g_settings_reset (settings, keys[i]);
}
+ g_settings_schema_unref (schema);
g_strfreev (keys);
}
main (int argc, char **argv)
{
void (* function) (void);
+ gboolean need_settings;
#ifdef G_OS_WIN32
gchar *tmp;
argc -= 2;
}
+ need_settings = TRUE;
+
if (strcmp (argv[1], "help") == 0)
return gsettings_help (TRUE, argv[2]);
function = gsettings_list_relocatable_schemas;
else if (argc == 3 && strcmp (argv[1], "list-keys") == 0)
- function = gsettings_list_keys;
+ {
+ need_settings = FALSE;
+ function = gsettings_list_keys;
+ }
else if (argc == 3 && strcmp (argv[1], "list-children") == 0)
function = gsettings_list_children;
function = gsettings_list_recursively;
else if (argc == 4 && strcmp (argv[1], "range") == 0)
- function = gsettings_range;
+ {
+ need_settings = FALSE;
+ function = gsettings_range;
+ }
else if (argc == 4 && strcmp (argv[1], "get") == 0)
function = gsettings_get;
parts = g_strsplit (argv[2], ":", 2);
global_schema = g_settings_schema_source_lookup (global_schema_source, parts[0], TRUE);
- if (parts[1])
- {
- if (!check_relocatable_schema (global_schema, parts[0]) || !check_path (parts[1]))
- return 1;
- global_settings = g_settings_new_full (global_schema, NULL, parts[1]);
+ if (need_settings)
+ {
+ if (parts[1])
+ {
+ if (!check_relocatable_schema (global_schema, parts[0]) || !check_path (parts[1]))
+ return 1;
+
+ global_settings = g_settings_new_full (global_schema, NULL, parts[1]);
+ }
+ else
+ {
+ if (!check_schema (global_schema, parts[0]))
+ return 1;
+
+ global_settings = g_settings_new_full (global_schema, NULL, NULL);
+ }
}
else
{
- if (!check_schema (global_schema, parts[0]))
- return 1;
-
- global_settings = g_settings_new_full (global_schema, NULL, NULL);
+ /* If the user has given a path then we enforce that we have a
+ * relocatable schema, but if they didn't give a path then it
+ * doesn't matter what type of schema we have (since it's
+ * reasonable to ask for introspection information on a
+ * relocatable schema without having to give the path).
+ */
+ if (parts[1])
+ {
+ if (!check_relocatable_schema (global_schema, parts[0]) || !check_path (parts[1]))
+ return 1;
+ }
+ else
+ {
+ if (global_schema == NULL)
+ {
+ g_printerr (_("No such schema '%s'\n"), parts[0]);
+ return 1;
+ }
+ }
}
g_strfreev (parts);