summaryrefslogtreecommitdiffstats
path: root/src/gui/PluginMenu.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-01-07 04:53:47 +0000
committerDavid Robillard <d@drobilla.net>2014-01-07 04:53:47 +0000
commit2aa1cf33b26c76b024913d1994066c627075bbbd (patch)
tree3b9f05646e069345792ff214bf91ef57eab4927b /src/gui/PluginMenu.hpp
parentd30907023903bc7b4a2de16d3fe5d7674861e394 (diff)
downloadingen-2aa1cf33b26c76b024913d1994066c627075bbbd.tar.gz
ingen-2aa1cf33b26c76b024913d1994066c627075bbbd.tar.bz2
ingen-2aa1cf33b26c76b024913d1994066c627075bbbd.zip
Factor out plugin menu code into a separate class.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5297 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui/PluginMenu.hpp')
-rw-r--r--src/gui/PluginMenu.hpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/gui/PluginMenu.hpp b/src/gui/PluginMenu.hpp
new file mode 100644
index 00000000..54624104
--- /dev/null
+++ b/src/gui/PluginMenu.hpp
@@ -0,0 +1,79 @@
+/*
+ This file is part of Ingen.
+ Copyright 2014 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or any later version.
+
+ Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef INGEN_GUI_PLUGINMENU_HPP
+#define INGEN_GUI_PLUGINMENU_HPP
+
+#include <map>
+#include <set>
+#include <string>
+
+#include <gtkmm/menu.h>
+
+#include "ingen/World.hpp"
+#include "ingen/types.hpp"
+#include "lilv/lilv.h"
+
+namespace Ingen {
+
+namespace Client { class PluginModel; }
+
+namespace GUI {
+
+/**
+ Type-hierarchical plugin menu.
+
+ @ingroup GUI
+*/
+class PluginMenu : public Gtk::Menu
+{
+public:
+ PluginMenu(Ingen::World& world);
+
+ void add_plugin(SPtr<Client::PluginModel> p);
+
+ sigc::signal< void, WPtr<Client::PluginModel> > signal_load_plugin;
+
+private:
+ struct MenuRecord {
+ MenuRecord(Gtk::MenuItem* i, Gtk::Menu* m) : item(i), menu(m) {}
+ Gtk::MenuItem* item;
+ Gtk::Menu* menu;
+ };
+
+ typedef std::multimap<const std::string, const LilvPluginClass*> LV2Children;
+ typedef std::multimap<const std::string, MenuRecord> ClassMenus;
+
+ /// Recursively add hierarchy rooted at @a plugin_class to @a menu.
+ size_t build_plugin_class_menu(Gtk::Menu* menu,
+ const LilvPluginClass* plugin_class,
+ const LilvPluginClasses* classes,
+ const LV2Children& children,
+ std::set<const char*>& ancestors);
+
+ void add_plugin_to_menu(MenuRecord& menu, SPtr<Client::PluginModel> p);
+
+ void load_plugin(WPtr<Client::PluginModel> weak_plugin);
+
+ Ingen::World& _world;
+ MenuRecord _classless_menu;
+ ClassMenus _class_menus;
+};
+
+} // namespace GUI
+} // namespace Ingen
+
+#endif // INGEN_GUI_PLUGINMENU_HPP