summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-07-04 19:15:50 +0000
committerDavid Robillard <d@drobilla.net>2011-07-04 19:15:50 +0000
commit86560309aa26b8cbb08bcfab85c7bc50a87794ab (patch)
tree6732b1b5ac06e0cfdaeefad56250fba92f5b8561 /src
parent6201df44e0187cb0606aaf1b9858c099db2a93c6 (diff)
downloadingen-86560309aa26b8cbb08bcfab85c7bc50a87794ab.tar.gz
ingen-86560309aa26b8cbb08bcfab85c7bc50a87794ab.tar.bz2
ingen-86560309aa26b8cbb08bcfab85c7bc50a87794ab.zip
Simplify FlowCanvas menu API, and fix crashing Ingen menus (ticket #721).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3411 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/gui/NodeModule.cpp9
-rw-r--r--src/gui/NodeModule.hpp2
-rw-r--r--src/gui/ObjectMenu.cpp9
-rw-r--r--src/gui/PatchPortModule.cpp9
-rw-r--r--src/gui/PatchPortModule.hpp2
-rw-r--r--src/gui/Port.cpp12
-rw-r--r--src/gui/Port.hpp2
-rw-r--r--src/gui/PortMenu.cpp8
8 files changed, 27 insertions, 26 deletions
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index 07d759c5..ab282714 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -74,16 +74,17 @@ NodeModule::~NodeModule()
delete win; // Will be removed from window factory via signal
}
-void
-NodeModule::create_menu()
+bool
+NodeModule::show_menu(GdkEventButton* ev)
{
- WidgetFactory::get_widget_derived("object_menu", _menu);
+ WidgetFactory::get_widget_derived("node_menu", _menu);
_menu->init(_node);
_menu->signal_embed_gui.connect(
sigc::mem_fun(this, &NodeModule::embed_gui));
_menu->signal_popup_gui.connect(
sigc::hide_return(sigc::mem_fun(this, &NodeModule::popup_gui)));
- set_menu(_menu);
+ _menu->popup(ev->button, ev->time);
+ return true;
}
NodeModule*
diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp
index d275b648..b833bf82 100644
--- a/src/gui/NodeModule.hpp
+++ b/src/gui/NodeModule.hpp
@@ -85,7 +85,7 @@ protected:
void plugin_changed();
void set_control_values();
- void create_menu();
+ bool show_menu(GdkEventButton* ev);
SharedPtr<const NodeModel> _node;
NodeMenu* _menu;
diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp
index 2fa14778..b97aa412 100644
--- a/src/gui/ObjectMenu.cpp
+++ b/src/gui/ObjectMenu.cpp
@@ -16,12 +16,16 @@
*/
#include <utility>
+
#include <gtkmm.h>
+
#include "ingen/ServerInterface.hpp"
-#include "shared/LV2URIMap.hpp"
#include "ingen/client/ObjectModel.hpp"
+#include "shared/LV2URIMap.hpp"
+
#include "App.hpp"
#include "ObjectMenu.hpp"
+#include "WidgetFactory.hpp"
#include "WindowFactory.hpp"
using namespace Raul;
@@ -30,7 +34,7 @@ namespace Ingen {
namespace GUI {
ObjectMenu::ObjectMenu(BaseObjectType* cobject,
- const Glib::RefPtr<Gtk::Builder>& xml)
+ const Glib::RefPtr<Gtk::Builder>& deriv_xml)
: Gtk::Menu(cobject)
, _polyphonic_menuitem(NULL)
, _disconnect_menuitem(NULL)
@@ -39,6 +43,7 @@ ObjectMenu::ObjectMenu(BaseObjectType* cobject,
, _properties_menuitem(NULL)
, _enable_signal(false)
{
+ Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("object_menu");
xml->get_widget("object_learn_menuitem", _learn_menuitem);
xml->get_widget("object_unlearn_menuitem", _unlearn_menuitem);
xml->get_widget("object_polyphonic_menuitem", _polyphonic_menuitem);
diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp
index 08889d8d..851f694b 100644
--- a/src/gui/PatchPortModule.cpp
+++ b/src/gui/PatchPortModule.cpp
@@ -62,7 +62,6 @@ PatchPortModule::create(PatchCanvas& canvas,
Port* port = Port::create(*ret, model, human, true);
ret->set_port(port);
- ret->set_menu(port->menu());
for (GraphObject::Properties::const_iterator m = model->properties().begin();
m != model->properties().end(); ++m)
@@ -71,13 +70,13 @@ PatchPortModule::create(PatchCanvas& canvas,
return ret;
}
-void
-PatchPortModule::create_menu()
+bool
+PatchPortModule::show_menu(GdkEventButton* ev)
{
WidgetFactory::get_widget_derived("object_menu", _menu);
_menu->init(_model, true);
-
- set_menu(_menu);
+ _menu->popup(ev->button, ev->time);
+ return true;
}
void
diff --git a/src/gui/PatchPortModule.hpp b/src/gui/PatchPortModule.hpp
index 42607315..b96d5dcb 100644
--- a/src/gui/PatchPortModule.hpp
+++ b/src/gui/PatchPortModule.hpp
@@ -65,7 +65,7 @@ protected:
PatchPortModule(PatchCanvas& canvas,
SharedPtr<const PortModel> model);
- void create_menu();
+ bool show_menu(GdkEventButton* ev);
void set_selected(bool b);
void set_port(Port* port) { _port = port; }
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index bc623950..ab48f30b 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -75,9 +75,6 @@ Port::Port(FlowCanvas::Module& module,
{
assert(pm);
- delete _menu;
- _menu = NULL;
-
ArtVpathDash* dash = this->dash();
_rect.property_dash() = dash;
set_border_width(dash ? 2.0 : 0.0);
@@ -121,13 +118,14 @@ Port::update_metadata()
}
}
-void
-Port::create_menu()
+bool
+Port::show_menu(GdkEventButton* ev)
{
PortMenu* menu = NULL;
- WidgetFactory::get_widget_derived("object_menu", menu);
+ WidgetFactory::get_widget_derived("port_menu", menu);
menu->init(model(), _flipped);
- set_menu(menu);
+ menu->popup(ev->button, ev->time);
+ return true;
}
void
diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp
index 3bc66cd3..65f7c2e2 100644
--- a/src/gui/Port.hpp
+++ b/src/gui/Port.hpp
@@ -50,7 +50,7 @@ public:
SharedPtr<const PortModel> model() const { return _port_model.lock(); }
- void create_menu();
+ bool show_menu(GdkEventButton* ev);
void update_metadata();
virtual void set_control(float value, bool signal);
diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp
index 973f7277..d958b278 100644
--- a/src/gui/PortMenu.cpp
+++ b/src/gui/PortMenu.cpp
@@ -64,19 +64,17 @@ PortMenu::init(SharedPtr<const PortModel> port, bool patch_port)
if (port->is_a(PortType::EVENTS))
_polyphonic_menuitem->hide();
+ _port_menu->remove(*_reset_range_menuitem);
+ _port_menu->remove(*_set_min_menuitem);
+ _port_menu->remove(*_set_max_menuitem);
if (App::instance().can_control(port.get()) && port->is_numeric()) {
_learn_menuitem->show();
_unlearn_menuitem->show();
items().push_front(Gtk::Menu_Helpers::SeparatorElem());
- _port_menu->remove(*_reset_range_menuitem);
insert(*_reset_range_menuitem, 0);
-
- _port_menu->remove(*_set_max_menuitem);
insert(*_set_max_menuitem, 0);
-
- _port_menu->remove(*_set_min_menuitem);
insert(*_set_min_menuitem, 0);
}