]> sigrok.org Git - pulseview.git/commitdiff
Settings: About: alpha-sort list of protocol decoders
authorGerhard Sittig <redacted>
Sun, 16 Apr 2017 19:34:05 +0000 (21:34 +0200)
committerGerhard Sittig <redacted>
Sun, 16 Apr 2017 19:34:05 +0000 (21:34 +0200)
Sort the list of protocol decoders in the "About" page like
sigrok-cli(1) does.

pv/dialogs/settings.cpp

index 32b1c207677979f32b285426bf5b9da9b395726a..15655a7065cb32363897012f26e7d7305f3db2c1 100644 (file)
@@ -148,6 +148,17 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const
        return form;
 }
 
+#ifdef ENABLE_DECODE
+static gint sort_pds(gconstpointer a, gconstpointer b)
+{
+       const struct srd_decoder *sda, *sdb;
+
+       sda = (const struct srd_decoder *)a;
+       sdb = (const struct srd_decoder *)b;
+       return strcmp(sda->id, sdb->id);
+}
+#endif
+
 QWidget *Settings::get_about_page(QWidget *parent) const
 {
 #ifdef ENABLE_DECODE
@@ -211,12 +222,15 @@ QWidget *Settings::get_about_page(QWidget *parent) const
 #ifdef ENABLE_DECODE
        s.append("<tr><td colspan=\"2\"><b>" +
                tr("Supported protocol decoders:") + "</b></td></tr>");
-       for (const GSList *l = srd_decoder_list(); l; l = l->next) {
+       GSList *sl = g_slist_copy((GSList *)srd_decoder_list());
+       sl = g_slist_sort(sl, sort_pds);
+       for (const GSList *l = sl; l; l = l->next) {
                dec = (struct srd_decoder *)l->data;
                s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
                        .arg(QString::fromUtf8(dec->id),
                                QString::fromUtf8(dec->longname)));
        }
+       g_slist_free(sl);
 #endif
 
        s.append("</table>");