Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: Sort web-settings options by name #82

Merged
merged 1 commit into from
Mar 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion core/cog-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ option_entry_parse_to_property (const char *option,
return TRUE;
}

int
entry_comparator (const void *p1, const void *p2)
{
GOptionEntry *e1 = (GOptionEntry *) p1;
GOptionEntry *e2 = (GOptionEntry *) p2;
return g_strcmp0 (e1->long_name, e2->long_name);
}

GOptionEntry*
cog_option_entries_from_class (GObjectClass *klass)
Expand All @@ -265,7 +272,8 @@ cog_option_entries_from_class (GObjectClass *klass)

g_autofree GOptionEntry *entries = g_new0 (GOptionEntry, n_properties + 1);

for (unsigned i = 0, e = 0; i < n_properties; i++) {
unsigned e = 0;
for (unsigned i = 0; i < n_properties; i++) {
GParamSpec *prop = properties[i];

// Pick only writable properties.
Expand Down Expand Up @@ -301,5 +309,8 @@ cog_option_entries_from_class (GObjectClass *klass)
entry->flags |= G_OPTION_FLAG_OPTIONAL_ARG;
}

// Sort entries by long name.
qsort (entries, e, sizeof (GOptionEntry), entry_comparator);

return g_steal_pointer (&entries);
}