From: Gerhard Sittig Date: Sun, 16 Apr 2017 19:34:05 +0000 (+0200) Subject: Settings: About: alpha-sort list of protocol decoders X-Git-Tag: pulseview-0.4.0~99 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=fe934a93e0dbdab4746091738450f9198a809666 Settings: About: alpha-sort list of protocol decoders Sort the list of protocol decoders in the "About" page like sigrok-cli(1) does. --- diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index 32b1c207..15655a70 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -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("Supported protocol decoders:") + ""); - 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("%1%2") .arg(QString::fromUtf8(dec->id), QString::fromUtf8(dec->longname))); } + g_slist_free(sl); #endif s.append("");