summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Plugin.H8
-rw-r--r--src/Fl_Preferences.cxx22
2 files changed, 28 insertions, 2 deletions
diff --git a/FL/Fl_Plugin.H b/FL/Fl_Plugin.H
index 6342c7ec4..d2b1dd1bd 100644
--- a/FL/Fl_Plugin.H
+++ b/FL/Fl_Plugin.H
@@ -18,9 +18,12 @@
Fl_Plugin class . */
#ifndef Fl_Plugin_H
-# define Fl_Plugin_H
+#define Fl_Plugin_H
-# include "Fl_Preferences.H"
+#include "Fl_Preferences.H"
+
+#include <string>
+#include <vector>
/**
@@ -83,6 +86,7 @@ public:
static void removePlugin(Fl_Preferences::ID id);
static int load(const char *filename);
static int loadAll(const char *dirpath, const char *pattern=0);
+ static std::vector<std::string> klass_list();
};
diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx
index 94b17e994..aa77a4e61 100644
--- a/src/Fl_Preferences.cxx
+++ b/src/Fl_Preferences.cxx
@@ -2118,3 +2118,25 @@ int Fl_Plugin_Manager::loadAll(const char *dirpath, const char *pattern) {
free(dir);
return 0;
}
+
+/**
+ Return a list of all plugin klasses that have been registered so far.
+ The returned strings can be used to crate a manager for the klass of
+ plugins, which in turn can be used to list plugins for that klass.
+ ```
+ auto kl = Fl_Plugin_Manager::klass_list();
+ for (auto &k: kl) {
+ Fl_Plugin_Manager m { k.c_str() };
+ std::cout << m.plugins() << "plugins have registered for klass" << k << std::endl;
+ }
+ ```
+ \return a copy of a vector of strings
+ */
+std::vector<std::string> Fl_Plugin_Manager::klass_list() {
+ Fl_Preferences p(0, "plugins");
+ std::vector<std::string> pm;
+ for (int i = 0; i < p.groups(); i++) {
+ pm.push_back(p.group(i));
+ }
+ return pm;
+}