diff options
author | David Robillard <d@drobilla.net> | 2008-08-14 05:09:14 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-14 05:09:14 +0000 |
commit | ce208602f25d443d4f721d75c9bd9c884ba9e9a6 (patch) | |
tree | 4d423d423739f9ef9bade7968bf60ae847925952 /src | |
parent | d09cfd0f5e6a1290ed5e90959f633b3c2d3e9386 (diff) | |
download | ingen-ce208602f25d443d4f721d75c9bd9c884ba9e9a6.tar.gz ingen-ce208602f25d443d4f721d75c9bd9c884ba9e9a6.tar.bz2 ingen-ce208602f25d443d4f721d75c9bd9c884ba9e9a6.zip |
Defer menu creation until it is actually requested (speeds up startup time-to-patch-window considerably).
Handle new plugins being presented after initialization in plugin menu and dialog.
git-svn-id: http://svn.drobilla.net/lad/ingen@1372 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/client/Store.cpp | 1 | ||||
-rw-r--r-- | src/libs/client/Store.hpp | 1 | ||||
-rw-r--r-- | src/libs/gui/LoadPluginWindow.cpp | 37 | ||||
-rw-r--r-- | src/libs/gui/LoadPluginWindow.hpp | 7 | ||||
-rw-r--r-- | src/libs/gui/PatchCanvas.cpp | 84 | ||||
-rw-r--r-- | src/libs/gui/PatchCanvas.hpp | 7 |
6 files changed, 88 insertions, 49 deletions
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index 1eea354a..53b99f8d 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -336,6 +336,7 @@ Store::add_plugin(SharedPtr<PluginModel> pm) // FIXME: dupes? merge, like with objects? _plugins[pm->uri()] = pm; + signal_new_plugin(pm); //cerr << "Plugin: " << pm->uri() << ", # plugins: " << _plugins.size() << endl; } diff --git a/src/libs/client/Store.hpp b/src/libs/client/Store.hpp index 443a411f..70f11142 100644 --- a/src/libs/client/Store.hpp +++ b/src/libs/client/Store.hpp @@ -70,6 +70,7 @@ public: const Objects& objects() const { return _objects; } sigc::signal<void, SharedPtr<ObjectModel> > signal_new_object; + sigc::signal<void, SharedPtr<PluginModel> > signal_new_plugin; private: diff --git a/src/libs/gui/LoadPluginWindow.cpp b/src/libs/gui/LoadPluginWindow.cpp index f0754cb9..99ab54c2 100644 --- a/src/libs/gui/LoadPluginWindow.cpp +++ b/src/libs/gui/LoadPluginWindow.cpp @@ -36,9 +36,10 @@ namespace Ingen { namespace GUI { LoadPluginWindow::LoadPluginWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml) -: Gtk::Window(cobject), - _has_shown(false), - _plugin_name_offset(0) + : Gtk::Window(cobject) + , _plugin_name_offset(0) + , _has_shown(false) + , _refresh_list(true) { xml->get_widget("load_plugin_plugins_treeview", _plugins_treeview); xml->get_widget("load_plugin_polyphonic_checkbutton", _polyphonic_checkbutton); @@ -173,20 +174,16 @@ void LoadPluginWindow::on_show() { if (!_has_shown) { - set_plugins(App::instance().store()->plugins()); - - // Center on patch window - /*int _w, _h; - get_size(_w, _h); - - int parent_x, parent_y, parent_w, parent_h; - _patch_controller->window()->get_position(parent_x, parent_y); - _patch_controller->window()->get_size(parent_w, parent_h); - - move(parent_x + parent_w/2 - _w/2, parent_y + parent_h/2 - _h/2); - */ + App::instance().store()->signal_new_plugin.connect( + sigc::mem_fun(this, &LoadPluginWindow::add_plugin)); _has_shown = true; } + + if (_refresh_list) { + set_plugins(App::instance().store()->plugins()); + _refresh_list = false; + } + Gtk::Window::on_show(); } @@ -248,6 +245,16 @@ LoadPluginWindow::set_plugins(const Raul::Table<string, SharedPtr<PluginModel> > void +LoadPluginWindow::new_plugin(SharedPtr<PluginModel> pm) +{ + if (is_visible()) + add_plugin(pm); + else + _refresh_list = true; +} + + +void LoadPluginWindow::add_plugin(SharedPtr<PluginModel> plugin) { Gtk::TreeModel::iterator iter = _plugins_liststore->append(); diff --git a/src/libs/gui/LoadPluginWindow.hpp b/src/libs/gui/LoadPluginWindow.hpp index da87be79..ef1420a0 100644 --- a/src/libs/gui/LoadPluginWindow.hpp +++ b/src/libs/gui/LoadPluginWindow.hpp @@ -96,7 +96,6 @@ public: void set_plugins(const Raul::Table<string, SharedPtr<PluginModel> >& m); void add_plugin(SharedPtr<PluginModel> plugin); - bool has_shown() const { return _has_shown; } void present(SharedPtr<PatchModel> patch, GraphObject::Variables data); @@ -111,6 +110,8 @@ private: void filter_changed(); void clear_clicked(); void name_changed(); + + void new_plugin(SharedPtr<PluginModel> plugin); int plugin_compare(const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b); @@ -123,8 +124,6 @@ private: SharedPtr<PatchModel> _patch; - bool _has_shown; // plugin list only populated on show to speed patch window creation - Glib::RefPtr<Gtk::ListStore> _plugins_liststore; ModelColumns _plugins_columns; @@ -135,6 +134,8 @@ private: int _plugin_name_offset; // see comments for generate_plugin_name + bool _has_shown; + bool _refresh_list; Gtk::TreeView* _plugins_treeview; Gtk::CheckButton* _polyphonic_checkbutton; Gtk::Entry* _node_name_entry; diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index 0fbf1854..a43ebcf3 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -50,10 +50,12 @@ namespace GUI { PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height) -:Canvas(width, height), - _patch(patch), - _last_click_x(0), - _last_click_y(0) + : Canvas(width, height) + , _patch(patch) + , _last_click_x(0) + , _last_click_y(0) + , _refresh_menu(false) + , _internal_menu(NULL) { Glib::RefPtr<Gnome::Glade::Xml> xml = GladeFactory::new_glade_reference(); xml->get_widget("canvas_menu", _menu); @@ -112,12 +114,6 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height) _menu_add_button_control->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_control), BUTTON));*/ - build_internal_menu(); - -#ifdef HAVE_SLV2 - build_plugin_menu(); -#endif - // Connect to model signals to track state _patch->signal_new_node.connect(sigc::mem_fun(this, &PatchCanvas::add_node)); _patch->signal_removed_node.connect(sigc::mem_fun(this, &PatchCanvas::remove_node)); @@ -126,6 +122,8 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height) _patch->signal_new_connection.connect(sigc::mem_fun(this, &PatchCanvas::connection)); _patch->signal_removed_connection.connect(sigc::mem_fun(this, &PatchCanvas::disconnection)); + App::instance().store()->signal_new_plugin.connect(sigc::mem_fun(this, &PatchCanvas::add_plugin)); + // Connect widget signals to do things _menu_load_plugin->signal_activate().connect(sigc::mem_fun(this, &PatchCanvas::menu_load_plugin)); _menu_load_patch->signal_activate().connect(sigc::mem_fun(this, &PatchCanvas::menu_load_patch)); @@ -134,27 +132,43 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height) void -PatchCanvas::build_internal_menu() +PatchCanvas::show_menu(GdkEvent* event) { - _menu->items().push_back(Gtk::Menu_Helpers::ImageMenuElem("Internal", - *(manage(new Gtk::Image(Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU))))); + if (!_internal_menu || !_plugin_menu || _refresh_menu) { + build_internal_menu(); +#ifdef HAVE_SLV2 + build_plugin_menu(); +#endif + _refresh_menu = false; + } + _menu->popup(event->button.button, event->button.time); +} + - Gtk::MenuItem* internal_menu_item = &(_menu->items().back()); - Gtk::Menu* internal_menu = Gtk::manage(new Gtk::Menu()); - internal_menu_item->set_submenu(*internal_menu); +void +PatchCanvas::build_internal_menu() +{ + if (_internal_menu) { + _internal_menu->items().clear(); + } else { + _menu->items().push_back(Gtk::Menu_Helpers::ImageMenuElem("Internal", + *(manage(new Gtk::Image(Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU))))); + Gtk::MenuItem* internal_menu_item = &(_menu->items().back()); + _internal_menu = Gtk::manage(new Gtk::Menu()); + internal_menu_item->set_submenu(*_internal_menu); + _menu->reorder_child(*internal_menu_item, 2); + } const Store::Plugins& plugins = App::instance().store()->plugins(); - // Add LV2 plugins + // Add Internal plugins for (Store::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) { SharedPtr<PluginModel> p = i->second; if (p->type() == Plugin::Internal) { - internal_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p->name(), + _internal_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p->name(), sigc::bind(sigc::mem_fun(this, &PatchCanvas::load_plugin), p))); } } - - _menu->reorder_child(*internal_menu_item, 2); } @@ -215,18 +229,22 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu, void PatchCanvas::build_plugin_menu() { - _menu->items().push_back(Gtk::Menu_Helpers::ImageMenuElem("Plugin", - *(manage(new Gtk::Image(Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU))))); - Gtk::MenuItem* plugin_menu_item = &(_menu->items().back()); - Gtk::Menu* plugin_menu = Gtk::manage(new Gtk::Menu()); - plugin_menu_item->set_submenu(*plugin_menu); - _menu->reorder_child(*plugin_menu_item, 3); + if (_plugin_menu) { + _plugin_menu->items().clear(); + } else { + _menu->items().push_back(Gtk::Menu_Helpers::ImageMenuElem("Plugin", + *(manage(new Gtk::Image(Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU))))); + Gtk::MenuItem* plugin_menu_item = &(_menu->items().back()); + _plugin_menu = Gtk::manage(new Gtk::Menu()); + plugin_menu_item->set_submenu(*_plugin_menu); + _menu->reorder_child(*plugin_menu_item, 3); + } Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex()); SLV2PluginClass lv2_plugin = slv2_world_get_plugin_class(PluginModel::slv2_world()); SLV2PluginClasses classes = slv2_world_get_plugin_classes(PluginModel::slv2_world()); - build_plugin_class_menu(plugin_menu, lv2_plugin, classes); + build_plugin_class_menu(_plugin_menu, lv2_plugin, classes); } #endif @@ -268,6 +286,13 @@ PatchCanvas::arrange(bool ingen_doesnt_use_length_hints) (*i)->store_location(); } + +void +PatchCanvas::add_plugin(SharedPtr<PluginModel> pm) +{ + _refresh_menu = true; +} + void PatchCanvas::add_node(SharedPtr<NodeModel> nm) @@ -540,10 +565,11 @@ PatchCanvas::copy_selection() Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); clipboard->set_text(result); } - + string -PatchCanvas::generate_port_name(const string& base) { +PatchCanvas::generate_port_name(const string& base) +{ string name = base; char num_buf[5]; diff --git a/src/libs/gui/PatchCanvas.hpp b/src/libs/gui/PatchCanvas.hpp index bb766314..3998532d 100644 --- a/src/libs/gui/PatchCanvas.hpp +++ b/src/libs/gui/PatchCanvas.hpp @@ -67,6 +67,7 @@ public: void build(); void arrange(bool use_length_hints); + void add_plugin(SharedPtr<PluginModel> pm); void add_node(SharedPtr<NodeModel> nm); void remove_node(SharedPtr<NodeModel> nm); void add_port(SharedPtr<PortModel> pm); @@ -79,8 +80,7 @@ public: void destroy_selection(); void copy_selection(); - void show_menu(GdkEvent* event) - { _menu->popup(event->button.button, event->button.time); } + void show_menu(GdkEvent* event); bool canvas_key_event(GdkEventKey* event); @@ -123,7 +123,10 @@ private: int _last_click_x; int _last_click_y; + bool _refresh_menu; Gtk::Menu* _menu; + Gtk::Menu* _internal_menu; + Gtk::Menu* _plugin_menu; /*Gtk::MenuItem* _menu_add_number_control; Gtk::MenuItem* _menu_add_button_control;*/ Gtk::MenuItem* _menu_add_audio_input; |