From 5ae4d4d5e805e828b51b98767ac51da24c3b21f1 Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Sun, 21 Oct 2007 19:46:07 +0000
Subject: Fix various client-side variable state problems. Fix port ranges.
 Close ticket 102.

git-svn-id: http://svn.drobilla.net/lad/ingen@895 a436a847-0d15-0410-975c-d299462d15a1
---
 src/libs/gui/ControlGroups.cpp     | 12 ++++++++++++
 src/libs/gui/ControlGroups.hpp     |  2 ++
 src/libs/gui/Port.cpp              |  5 ++---
 src/libs/gui/UploadPatchWindow.cpp |  4 ++--
 4 files changed, 18 insertions(+), 5 deletions(-)

(limited to 'src/libs/gui')

diff --git a/src/libs/gui/ControlGroups.cpp b/src/libs/gui/ControlGroups.cpp
index b7828a48..236f782e 100644
--- a/src/libs/gui/ControlGroups.cpp
+++ b/src/libs/gui/ControlGroups.cpp
@@ -127,6 +127,8 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
 	} else {
 		_slider->set_increments(0, 0);
 	}
+	
+	pm->signal_variable.connect(sigc::mem_fun(this, &SliderControlGroup::port_variable_change));
 
 	_slider->set_range(std::min(min, pm->value()), std::max(max, pm->value()));
 	//_value_spinner->set_range(min, max);
@@ -184,6 +186,16 @@ SliderControlGroup::set_value(float val)
 	_enable_signal = true;
 }
 
+	
+void
+SliderControlGroup::port_variable_change(const string& key, const Atom& value)
+{
+	if ( (key == "ingen:minimum") && value.type() == Atom::FLOAT)
+		set_range(value.get_float(), _slider->get_adjustment()->get_upper());
+	else if ( (key == "ingen:maximum") && value.type() == Atom::FLOAT)
+		set_range(_slider->get_adjustment()->get_lower(), value.get_float());
+}
+
 
 void
 SliderControlGroup::set_range(float min, float max)
diff --git a/src/libs/gui/ControlGroups.hpp b/src/libs/gui/ControlGroups.hpp
index 15e5a6ea..89f26a6b 100644
--- a/src/libs/gui/ControlGroups.hpp
+++ b/src/libs/gui/ControlGroups.hpp
@@ -82,6 +82,8 @@ private:
 
 	void set_value(float value);
 	void set_range(float min, float max);
+	
+	void port_variable_change(const string& key, const Raul::Atom& value);
 
 	void update_range();
 	void update_value_from_slider();
diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp
index 04d45f1d..97a06bcd 100644
--- a/src/libs/gui/Port.cpp
+++ b/src/libs/gui/Port.cpp
@@ -122,11 +122,10 @@ Port::set_control(float value, bool signal)
 void
 Port::variable_change(const string& key, const Atom& value)
 {
-	if ( (key == "ingen:minimum") && value.type() == Atom::FLOAT) {
+	if ( (key == "ingen:minimum") && value.type() == Atom::FLOAT)
 		set_control_min(value.get_float());
-	} else if ( (key == "ingen:maximum") && value.type() == Atom::FLOAT) {
+	else if ( (key == "ingen:maximum") && value.type() == Atom::FLOAT)
 		set_control_max(value.get_float());
-	}
 }
 
 
diff --git a/src/libs/gui/UploadPatchWindow.cpp b/src/libs/gui/UploadPatchWindow.cpp
index c64bac50..d404cbcb 100644
--- a/src/libs/gui/UploadPatchWindow.cpp
+++ b/src/libs/gui/UploadPatchWindow.cpp
@@ -238,8 +238,8 @@ UploadPatchWindow::upload_clicked()
 	Glib::ustring short_name = _short_name_entry->get_text();
 
 	GraphObject::Variables extra_rdf;
-	extra_rdf.insert(make_pair("lv2:symbol", Atom(symbol)));
-	extra_rdf.insert(make_pair("doap:name", Atom(short_name)));
+	extra_rdf["lv2:symbol"] = Atom(symbol);
+	extra_rdf["doap:name"] =  Atom(short_name);
 
 	_response = 0;
 	_progress_pct = 0;
-- 
cgit v1.2.1