[glib: 1/2] Sort output of gsettings command-line tool
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] Sort output of gsettings command-line tool
- Date: Thu, 18 Nov 2021 12:40:41 +0000 (UTC)
commit 296a8c652206af7f2d65f72eb84af7b5bfa88d94
Author: Frederic Martinsons <frederic martinsons sigfox com>
Date: Thu Nov 18 08:59:43 2021 +0100
Sort output of gsettings command-line tool
Closes #1781
Signed-off-by: Frederic Martinsons <frederic martinsons sigfox com>
gio/gsettings-tool.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/gio/gsettings-tool.c b/gio/gsettings-tool.c
index 7559a6b1b..0c7763a39 100644
--- a/gio/gsettings-tool.c
+++ b/gio/gsettings-tool.c
@@ -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++)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]