diff options
Diffstat (limited to 'src/gui/URIEntry.hpp')
-rw-r--r-- | src/gui/URIEntry.hpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/gui/URIEntry.hpp b/src/gui/URIEntry.hpp new file mode 100644 index 00000000..d8f830d0 --- /dev/null +++ b/src/gui/URIEntry.hpp @@ -0,0 +1,70 @@ +/* + This file is part of Ingen. + Copyright 2015 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_URI_ENTRY_HPP +#define INGEN_GUI_URI_ENTRY_HPP + +#include <gtkmm/box.h> +#include <gtkmm/button.h> +#include <gtkmm/entry.h> +#include <gtkmm/menu.h> + +#include "lilv/lilv.h" + +namespace Ingen { +namespace GUI { + +class App; + +class URIEntry : public Gtk::HBox { +public: + /** Create a widget for entering URIs. + * + * If `types` is given, then a menu button will be shown which pops up a + * enu for easily choosing known values with valid types. + */ + URIEntry(App* app, + const std::set<Raul::URI>& types, + const std::string& value); + + std::string get_text() { return _entry->get_text(); } + Glib::SignalProxy0<void> signal_changed() { return _entry->signal_changed(); } + +private: + Gtk::Menu* build_value_menu(); + Gtk::Menu* build_subclass_menu(const LilvNode* klass); + + void add_leaf_menu_item(Gtk::Menu* menu, + const LilvNode* klass, + const std::string& label); + + void add_class_menu_item(Gtk::Menu* menu, + const LilvNode* klass, + const std::string& label); + + void uri_chosen(const std::string& uri); + bool menu_button_event(GdkEvent* ev); + + App* _app; + const std::set<Raul::URI> _types; + Gtk::Button* _menu_button; + Gtk::Entry* _entry; +}; + +} // namespace GUI +} // namespace Ingen + +#endif // INGEN_GUI_URI_ENTRY_HPP |