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

Sort plugins in settings dialog alphabetically #103

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/libaudcore/plugin-registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static constexpr aud::array<InputKey, const char *> input_key_names = {

static aud::array<PluginType, Index<PluginHandle *>> plugins;
static aud::array<PluginType, Index<PluginHandle *>> compatible;
static aud::array<PluginType, Index<PluginHandle *>> sorted; /* by name */
static aud::mutex mutex;
static bool modified = false;

Expand Down Expand Up @@ -209,6 +210,9 @@ void plugin_registry_cleanup()

for (auto & list : compatible)
list.clear();

for (auto & list : sorted)
list.clear();
}

static void transport_plugin_parse(PluginHandle * plugin, TextParser & parser)
Expand Down Expand Up @@ -442,8 +446,14 @@ void plugin_registry_prune()
{
plugins[type].remove_if(check_not_found);
plugins[type].sort(plugin_compare);

compatible[type].insert(plugins[type].begin(), 0, plugins[type].len());
compatible[type].remove_if(check_incompatible);

sorted[type].insert(compatible[type].begin(), 0, compatible[type].len());
sorted[type].sort([](PluginHandle * a, PluginHandle * b) {
return str_compare(aud_plugin_get_name(a), aud_plugin_get_name(b));
});
}
}

Expand Down Expand Up @@ -623,6 +633,11 @@ EXPORT const Index<PluginHandle *> & aud_plugin_list(PluginType type)
return compatible[type];
}

EXPORT const Index<PluginHandle *> & aud_plugin_list_sorted(PluginType type)
{
return sorted[type];
}

EXPORT const char * aud_plugin_get_name(PluginHandle * plugin)
{
return dgettext(plugin->domain, plugin->name);
Expand Down
1 change: 1 addition & 0 deletions src/libaudcore/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const void * aud_plugin_get_header(PluginHandle * plugin);
PluginHandle * aud_plugin_by_header(const void * header);

const Index<PluginHandle *> & aud_plugin_list(PluginType type);
const Index<PluginHandle *> & aud_plugin_list_sorted(PluginType type);

const char * aud_plugin_get_name(PluginHandle * plugin);
bool aud_plugin_has_about(PluginHandle * plugin);
Expand Down
2 changes: 1 addition & 1 deletion src/libaudgui/plugin-view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static void list_fill (GtkTreeView * tree, void * type)
gtk_tree_view_column_pack_start (col, rend, false);
gtk_tree_view_column_set_attributes (col, rend, "text", PVIEW_COL_NAME, nullptr);

for (PluginHandle * plugin : aud_plugin_list (aud::from_ptr<PluginType> (type)))
for (PluginHandle * plugin : aud_plugin_list_sorted (aud::from_ptr<PluginType> (type)))
add_to_list (model, plugin);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libaudqt/prefs-pluginlist-model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ QModelIndex PluginListModel::index(int row, int column,
if (cat < 0 || cat >= n_categories)
return QModelIndex();

auto & list = aud_plugin_list(categories[cat].type);
auto & list = aud_plugin_list_sorted(categories[cat].type);
if (row < 0 || row >= list.len())
return QModelIndex();

Expand Down