Merge branch 'fm/gsettings-output-sorted' into 'main'

Sort output of gsettings command-line tool

Closes #1781

See merge request GNOME/glib!2346
This commit is contained in:
Philip Withnall 2021-11-18 12:40:40 +00:00
commit c94f24cadd

View File

@ -112,11 +112,19 @@ check_path (const gchar *path)
return TRUE;
}
static int
qsort_cmp (const void *a,
const void *b)
{
return g_strcmp0 (*(gchar* const*)a, *(gchar* const*)b);
}
static void
output_list (gchar **list)
{
gint i;
qsort (list, g_strv_length (list), sizeof (gchar*), qsort_cmp);
for (i = 0; list[i]; i++)
g_print ("%s\n", list[i]);
}
@ -195,6 +203,7 @@ gsettings_list_children (void)
gint i;
children = g_settings_list_children (global_settings);
qsort (children, g_strv_length (children), sizeof (gchar*), qsort_cmp);
for (i = 0; children[i]; i++)
{
gsize len = strlen (children[i]);
@ -239,6 +248,7 @@ enumerate (GSettings *settings)
g_object_get (settings, "settings-schema", &schema, NULL);
keys = g_settings_schema_list_keys (schema);
qsort (keys, g_strv_length (keys), sizeof (gchar*), qsort_cmp);
for (i = 0; keys[i]; i++)
{
GVariant *value;
@ -263,6 +273,7 @@ list_recursively (GSettings *settings)
enumerate (settings);
children = g_settings_list_children (settings);
qsort (children, g_strv_length (children), sizeof (gchar*), qsort_cmp);
for (i = 0; children[i]; i++)
{
gboolean will_see_elsewhere = FALSE;
@ -306,6 +317,7 @@ gsettings_list_recursively (void)
gint i;
g_settings_schema_source_list_schemas (global_schema_source, TRUE, &schemas, NULL);
qsort (schemas, g_strv_length (schemas), sizeof (gchar*), qsort_cmp);
for (i = 0; schemas[i]; i++)
{