summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-13 21:49:19 +0000
committerDavid Robillard <d@drobilla.net>2010-02-13 21:49:19 +0000
commitb8cf49d04a2600f83767ddda46929d4d47adc3fd (patch)
treedfffc8f67bff91f82da254013634119ab8c2ec78 /src/gui
parent4750fff78baec94cb230b023ed29a7c4461c8544 (diff)
downloadingen-b8cf49d04a2600f83767ddda46929d4d47adc3fd.tar.gz
ingen-b8cf49d04a2600f83767ddda46929d4d47adc3fd.tar.bz2
ingen-b8cf49d04a2600f83767ddda46929d4d47adc3fd.zip
Make preset menu work when clicking items (previously only worked when pressing enter for mysterious crazy nonsensical reasons).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2441 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/NodeMenu.cpp37
-rw-r--r--src/gui/NodeMenu.hpp1
2 files changed, 27 insertions, 11 deletions
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index ae735ad6..aed7650c 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.cpp
@@ -16,6 +16,7 @@
*/
#include <gtkmm.h>
+#include "ingen-config.h"
#include "interface/EngineInterface.hpp"
#include "shared/LV2URIMap.hpp"
#include "client/NodeModel.hpp"
@@ -92,22 +93,28 @@ NodeMenu::init(SharedPtr<NodeModel> node)
"PREFIX dc: <http://dublincore.org/documents/dcmi-namespace/>\n"
"SELECT ?p ?name WHERE { <> pset:hasPreset ?p . ?p dc:title ?name }\n");
if (!slv2_results_finished(presets)) {
- items().push_front(Gtk::Menu_Helpers::SeparatorElem());
- items().push_front(Gtk::Menu_Helpers::ImageMenuElem("_Presets",
- *(manage(new Gtk::Image(Gtk::Stock::INDEX, Gtk::ICON_SIZE_MENU)))));
- Gtk::MenuItem* presets_menu_item = &(items().front());
_presets_menu = Gtk::manage(new Gtk::Menu());
- presets_menu_item->set_submenu(*_presets_menu);
for (; !slv2_results_finished(presets); slv2_results_next(presets)) {
SLV2Value uri = slv2_results_get_binding_value(presets, 0);
SLV2Value name = slv2_results_get_binding_value(presets, 1);
- Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(slv2_value_as_string(name)));
- _presets_menu->items().push_back(*item);
- item->show();
- item->signal_activate().connect(
- sigc::bind(sigc::mem_fun(this, &NodeMenu::on_preset_activated),
- string(slv2_value_as_string(uri))), false);
+ _presets_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(
+ slv2_value_as_string(name),
+ sigc::bind(
+ sigc::mem_fun(this, &NodeMenu::on_preset_activated),
+ string(slv2_value_as_string(uri)))));
+
+ // I have no idea why this is necessary, signal_activated doesn't work
+ // in this menu (and only this menu)
+ Gtk::MenuItem* item = &(_presets_menu->items().back());
+ item->signal_button_release_event().connect(
+ sigc::bind<0>(sigc::mem_fun(this, &NodeMenu::on_preset_clicked),
+ string(slv2_value_as_string(uri))));
}
+ items().push_front(Gtk::Menu_Helpers::SeparatorElem());
+ items().push_front(Gtk::Menu_Helpers::ImageMenuElem("_Presets",
+ *(manage(new Gtk::Image(Gtk::Stock::INDEX, Gtk::ICON_SIZE_MENU)))));
+ Gtk::MenuItem* presets_menu_item = &(items().front());
+ presets_menu_item->set_submenu(*_presets_menu);
}
slv2_results_free(presets);
}
@@ -190,6 +197,14 @@ NodeMenu::on_preset_activated(const std::string uri)
bool
+NodeMenu::on_preset_clicked(const std::string uri, GdkEventButton* ev)
+{
+ on_preset_activated(uri);
+ return false;
+}
+
+
+bool
NodeMenu::has_control_inputs()
{
const NodeModel* const nm = (NodeModel*)_object.get();
diff --git a/src/gui/NodeMenu.hpp b/src/gui/NodeMenu.hpp
index 7d2be982..1698e597 100644
--- a/src/gui/NodeMenu.hpp
+++ b/src/gui/NodeMenu.hpp
@@ -54,6 +54,7 @@ protected:
void on_menu_embed_gui();
void on_menu_randomize();
void on_preset_activated(const std::string uri);
+ bool on_preset_clicked(const std::string uri, GdkEventButton* ev);
Gtk::MenuItem* _controls_menuitem;
Gtk::MenuItem* _popup_gui_menuitem;