From aa309115304f1cae1938787bd487822687d499a4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 12 Apr 2007 03:40:37 +0000 Subject: Remote patch indexing, loading from online patch repository. git-svn-id: http://svn.drobilla.net/lad/ingen@446 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/ingenuity/LoadRemotePatchWindow.cpp | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/progs/ingenuity/LoadRemotePatchWindow.cpp') diff --git a/src/progs/ingenuity/LoadRemotePatchWindow.cpp b/src/progs/ingenuity/LoadRemotePatchWindow.cpp index 8f4fa3a2..19e206aa 100644 --- a/src/progs/ingenuity/LoadRemotePatchWindow.cpp +++ b/src/progs/ingenuity/LoadRemotePatchWindow.cpp @@ -19,6 +19,7 @@ #include #include #include +#include "raul/RDFQuery.h" #include "App.h" #include "Configuration.h" #include "PatchModel.h" @@ -26,6 +27,7 @@ #include "ThreadedLoader.h" using boost::optional; +using namespace Raul; namespace Ingenuity { @@ -34,20 +36,55 @@ LoadRemotePatchWindow::LoadRemotePatchWindow(BaseObjectType* cobject, const Glib : Gtk::Dialog(cobject), _replace(true) { + xml->get_widget("load_remote_patch_treeview", _treeview); xml->get_widget("load_remote_patch_uri_entry", _uri_entry); xml->get_widget("load_remote_patch_cancel_button", _cancel_button); xml->get_widget("load_remote_patch_open_button", _open_button); + _liststore = Gtk::ListStore::create(_columns); + _treeview->set_model(_liststore); + _treeview->append_column("Name", _columns._col_name); + _treeview->append_column("URI", _columns._col_uri); + + _selection = _treeview->get_selection(); + _selection->signal_changed().connect(sigc::mem_fun(this, &LoadRemotePatchWindow::patch_selected)); + _treeview->signal_row_activated().connect(sigc::mem_fun(this, &LoadRemotePatchWindow::patch_activated)); + _open_button->signal_clicked().connect(sigc::mem_fun(this, &LoadRemotePatchWindow::open_clicked)); _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &LoadRemotePatchWindow::cancel_clicked)); + _uri_entry->signal_changed().connect(sigc::mem_fun(this, &LoadRemotePatchWindow::uri_changed)); } void LoadRemotePatchWindow::present(SharedPtr patch, MetadataMap data) { + _liststore->clear(); + set_patch(patch); _initial_data = data; + + Namespaces namespaces; + namespaces["ingen"] = "http://drobilla.net/ns/ingen#"; + namespaces["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#"; + + RDFQuery query(namespaces, Glib::ustring( + "SELECT DISTINCT ?name ?uri FROM <> WHERE {" + " ?patch a ingen:Patch ;" + " rdfs:seeAlso ?uri ;" + " ingen:name ?name ." + "}")); + + RDFQuery::Results results = query.run("http://drobilla.net/ingen/index.ttl"); + + for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { + Gtk::TreeModel::iterator iter = _liststore->append(); + (*iter)[_columns._col_name] = (*i)["name"]; + (*iter)[_columns._col_uri] = (*i)["uri"]; + } + + _treeview->columns_autosize(); + Gtk::Window::present(); } @@ -63,6 +100,32 @@ LoadRemotePatchWindow::set_patch(SharedPtr patch) } +void +LoadRemotePatchWindow::uri_changed() +{ + _open_button->property_sensitive() = (_uri_entry->get_text().length() > 0); +} + + +void +LoadRemotePatchWindow::patch_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* col) +{ + open_clicked(); +} + + +void +LoadRemotePatchWindow::patch_selected() +{ + Gtk::TreeModel::iterator selected_i = _selection->get_selected(); + + if (selected_i) { // If anything is selected + const Glib::ustring uri = selected_i->get_value(_columns._col_uri); + _uri_entry->set_text(uri); + } +} + + void LoadRemotePatchWindow::open_clicked() { -- cgit v1.2.1