summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ganv/Port.hpp2
-rw-r--r--src/Canvas.cpp5
-rw-r--r--src/ganv-private.h1
-rw-r--r--src/port.c16
4 files changed, 20 insertions, 4 deletions
diff --git a/ganv/Port.hpp b/ganv/Port.hpp
index 431742b..980ddb0 100644
--- a/ganv/Port.hpp
+++ b/ganv/Port.hpp
@@ -46,6 +46,8 @@ public:
bool is_input,
uint32_t color);
+ RW_PROPERTY(gboolean, is_controllable)
+
METHODRET0(ganv_port, gboolean, is_input)
METHODRET0(ganv_port, gboolean, is_output)
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index 96b097f..4f3ca33 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -1341,7 +1341,7 @@ GanvCanvasImpl::connect_drag_handler(GdkEvent* event)
GanvNode* joinee = get_node_at(x, y);
- if (joinee) {
+ if (GANV_IS_PORT(joinee)) {
if (joinee == GANV_NODE(_connect_port)) {
// Drag ended on the same port it started on, port clicked
if (_selected_ports.empty()) {
@@ -1402,7 +1402,8 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
if (module && port->impl->control &&
(port->impl->is_input ||
- port_x < ganv_box_get_width(GANV_BOX(port)) / 2.0)) {
+ (port->impl->is_controllable &&
+ port_x < ganv_box_get_width(GANV_BOX(port)) / 2.0))) {
if (port->impl->control->is_toggle) {
if (port->impl->control->value >= 0.5) {
ganv_port_set_control_value_internal(port, 0.0);
diff --git a/src/ganv-private.h b/src/ganv-private.h
index fdcd210..2a4dbe2 100644
--- a/src/ganv-private.h
+++ b/src/ganv-private.h
@@ -135,6 +135,7 @@ typedef struct {
struct _GanvPortImpl {
GanvPortControl* control;
gboolean is_input;
+ gboolean is_controllable;
};
/* Text */
diff --git a/src/port.c b/src/port.c
index 4750064..e4c011b 100644
--- a/src/port.c
+++ b/src/port.c
@@ -40,7 +40,8 @@ static GanvBoxClass* parent_class;
enum {
PROP_0,
- PROP_IS_INPUT
+ PROP_IS_INPUT,
+ PROP_IS_CONTROLLABLE
};
enum {
@@ -56,7 +57,8 @@ ganv_port_init(GanvPort* port)
port->impl = G_TYPE_INSTANCE_GET_PRIVATE(
port, GANV_TYPE_PORT, GanvPortImpl);
- port->impl->is_input = TRUE;
+ port->impl->is_input = TRUE;
+ port->impl->is_controllable = FALSE;
}
static void
@@ -96,6 +98,7 @@ ganv_port_set_property(GObject* object,
switch (prop_id) {
SET_CASE(IS_INPUT, boolean, port->impl->is_input);
+ SET_CASE(IS_CONTROLLABLE, boolean, port->impl->is_controllable);
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -115,6 +118,7 @@ ganv_port_get_property(GObject* object,
switch (prop_id) {
GET_CASE(IS_INPUT, boolean, port->impl->is_input);
+ GET_CASE(IS_CONTROLLABLE, boolean, port->impl->is_controllable);
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -354,6 +358,14 @@ ganv_port_class_init(GanvPortClass* klass)
0,
G_PARAM_READWRITE));
+ g_object_class_install_property(
+ gobject_class, PROP_IS_CONTROLLABLE, g_param_spec_boolean(
+ "is-controllable",
+ _("Is controllable"),
+ _("Whether this port can be controlled by the user."),
+ 0,
+ G_PARAM_READWRITE));
+
port_signals[PORT_VALUE_CHANGED]
= g_signal_new("value-changed",
G_TYPE_FROM_CLASS(klass),