summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-06-09 04:51:32 +0000
committerDavid Robillard <d@drobilla.net>2013-06-09 04:51:32 +0000
commitfe81cb8af20ecbe721eba55d53fa62c5e2041421 (patch)
tree98e94e5dcf675054ac6023ddbccd44b1381ddda0 /src/gui
parentc8e00539e66bbe3584798ab8619f4b5927e83c2c (diff)
downloadingen-fe81cb8af20ecbe721eba55d53fa62c5e2041421.tar.gz
ingen-fe81cb8af20ecbe721eba55d53fa62c5e2041421.tar.bz2
ingen-fe81cb8af20ecbe721eba55d53fa62c5e2041421.zip
Support removing properties from the properties dialog.
You can definitely blow your leg off with this one, clever ontology awareness (e.g. required properties) would be good... git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5138 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/PropertiesWindow.cpp37
-rw-r--r--src/gui/PropertiesWindow.hpp25
2 files changed, 44 insertions, 18 deletions
diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp
index 2177de8c..50332c65 100644
--- a/src/gui/PropertiesWindow.cpp
+++ b/src/gui/PropertiesWindow.cpp
@@ -126,14 +126,18 @@ PropertiesWindow::add_property(const Raul::URI& uri, const Atom& value)
lilv_node_free(prop);
// Column 1: Value
- Gtk::Alignment* align = manage(new Gtk::Alignment(0.0, 0.5, 1.0, 0.0));
- Gtk::Widget* val_widget = create_value_widget(uri, value);
+ Gtk::Alignment* align = manage(new Gtk::Alignment(0.0, 0.5, 1.0, 0.0));
+ Gtk::CheckButton* present = manage(new Gtk::CheckButton());
+ Gtk::Widget* val_widget = create_value_widget(uri, value);
+ present->set_active(true);
if (val_widget) {
align->add(*val_widget);
}
_table->attach(*align, 1, 2, n_rows, n_rows + 1,
Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK);
- _records.insert(make_pair(uri, Record(value, align, n_rows)));
+ _table->attach(*present, 2, 3, n_rows, n_rows + 1,
+ Gtk::FILL, Gtk::SHRINK);
+ _records.insert(make_pair(uri, Record(value, align, n_rows, present)));
}
/** Set the node this window is associated with.
@@ -208,6 +212,8 @@ PropertiesWindow::set_object(SPtr<const ObjectModel> model)
_property_connection = model->signal_property().connect(
sigc::mem_fun(this, &PropertiesWindow::property_changed));
+ _property_removed_connection = model->signal_property_removed().connect(
+ sigc::mem_fun(this, &PropertiesWindow::property_removed));
}
Gtk::Widget*
@@ -323,6 +329,14 @@ PropertiesWindow::property_changed(const Raul::URI& predicate,
}
void
+PropertiesWindow::property_removed(const Raul::URI& predicate,
+ const Atom& value)
+{
+ // Bleh, there doesn't seem to be an easy way to remove a Gtk::Table row...
+ set_object(_model);
+}
+
+void
PropertiesWindow::value_edited(const Raul::URI& predicate)
{
Records::iterator r = _records.find(predicate);
@@ -446,16 +460,25 @@ PropertiesWindow::cancel_clicked()
void
PropertiesWindow::apply_clicked()
{
- Resource::Properties properties;
+ Resource::Properties remove;
+ Resource::Properties add;
for (const auto& r : _records) {
const Raul::URI& uri = r.first;
const Record& record = r.second;
- if (!_model->has_property(uri, record.value)) {
- properties.insert(make_pair(uri, record.value));
+ if (record.present_button->get_active()) {
+ if (!_model->has_property(uri, record.value)) {
+ add.insert(make_pair(uri, record.value));
+ }
+ } else {
+ remove.insert(make_pair(uri, record.value));
}
}
- _app->interface()->put(_model->uri(), properties);
+ if (remove.empty()) {
+ _app->interface()->put(_model->uri(), add);
+ } else {
+ _app->interface()->delta(_model->uri(), remove, add);
+ }
}
void
diff --git a/src/gui/PropertiesWindow.hpp b/src/gui/PropertiesWindow.hpp
index 7725706b..025c98ae 100644
--- a/src/gui/PropertiesWindow.hpp
+++ b/src/gui/PropertiesWindow.hpp
@@ -23,8 +23,9 @@
#include <gtkmm/box.h>
#include <gtkmm/builder.h>
#include <gtkmm/button.h>
-#include <gtkmm/liststore.h>
+#include <gtkmm/checkbutton.h>
#include <gtkmm/combobox.h>
+#include <gtkmm/liststore.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/table.h>
@@ -57,12 +58,13 @@ public:
private:
/** Record of a property (row in the table) */
struct Record {
- Record(const Atom& v, Gtk::Alignment* vw, int r)
- : value(v), value_widget(vw), row(r)
+ Record(const Atom& v, Gtk::Alignment* vw, int r, Gtk::CheckButton* cb)
+ : value(v), value_widget(vw), row(r), present_button(cb)
{}
- Atom value;
- Gtk::Alignment* value_widget;
- int row;
+ Atom value;
+ Gtk::Alignment* value_widget;
+ int row;
+ Gtk::CheckButton* present_button;
};
struct ComboColumns : public Gtk::TreeModel::ColumnRecord {
@@ -74,17 +76,17 @@ private:
Gtk::TreeModelColumn<Glib::ustring> uri_col;
};
- void add_property(const Raul::URI& uri,
- const Atom& value);
+ void add_property(const Raul::URI& uri,
+ const Atom& value);
- Gtk::Widget* create_value_widget(const Raul::URI& uri,
- const Atom& value);
+ Gtk::Widget* create_value_widget(const Raul::URI& uri,
+ const Atom& value);
- void init();
void reset();
void on_show();
void property_changed(const Raul::URI& predicate, const Atom& value);
+ void property_removed(const Raul::URI& predicate, const Atom& value);
void value_edited(const Raul::URI& predicate);
void key_changed();
void add_clicked();
@@ -100,6 +102,7 @@ private:
Glib::RefPtr<Gtk::ListStore> _key_store;
Glib::RefPtr<Gtk::ListStore> _value_store;
sigc::connection _property_connection;
+ sigc::connection _property_removed_connection;
Gtk::VBox* _vbox;
Gtk::ScrolledWindow* _scrolledwindow;
Gtk::Table* _table;