diff options
author | David Robillard <d@drobilla.net> | 2007-04-12 03:40:37 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-04-12 03:40:37 +0000 |
commit | aa309115304f1cae1938787bd487822687d499a4 (patch) | |
tree | 135264036a53421fd6d33a358a68e0affd13d672 /src | |
parent | 533402f16f6a7e6a9aa6df4186055690bce8e3ac (diff) | |
download | ingen-aa309115304f1cae1938787bd487822687d499a4.tar.gz ingen-aa309115304f1cae1938787bd487822687d499a4.tar.bz2 ingen-aa309115304f1cae1938787bd487822687d499a4.zip |
Remote patch indexing, loading from online patch repository.
git-svn-id: http://svn.drobilla.net/lad/ingen@446 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/progs/ingenuity/LoadRemotePatchWindow.cpp | 63 | ||||
-rw-r--r-- | src/progs/ingenuity/LoadRemotePatchWindow.h | 34 | ||||
-rw-r--r-- | src/progs/ingenuity/ingenuity.glade | 106 |
3 files changed, 169 insertions, 34 deletions
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 <sys/types.h> #include <dirent.h> #include <boost/optional/optional.hpp> +#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<PatchModel> 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(); } @@ -64,6 +101,32 @@ LoadRemotePatchWindow::set_patch(SharedPtr<PatchModel> 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() { Glib::ustring uri = _uri_entry->get_text(); diff --git a/src/progs/ingenuity/LoadRemotePatchWindow.h b/src/progs/ingenuity/LoadRemotePatchWindow.h index c7a8ee22..5c399888 100644 --- a/src/progs/ingenuity/LoadRemotePatchWindow.h +++ b/src/progs/ingenuity/LoadRemotePatchWindow.h @@ -28,7 +28,25 @@ using Ingen::Client::PatchModel; using Ingen::Client::MetadataMap; namespace Ingenuity { - + + +/** Columns for the remote patch list. + * + * \ingroup Ingenuity + */ +class PatchColumns : public Gtk::TreeModel::ColumnRecord +{ +public: + PatchColumns() { + add(_col_name); + add(_col_uri); + } + + Gtk::TreeModelColumn<Glib::ustring> _col_name; + Gtk::TreeModelColumn<Glib::ustring> _col_uri; +}; + + /* Load remote patch ("import location") dialog. * @@ -47,6 +65,9 @@ public: void present(SharedPtr<PatchModel> patch, MetadataMap data); private: + void patch_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* col); + void patch_selected(); + void uri_changed(); void open_clicked(); void cancel_clicked(); @@ -54,10 +75,15 @@ private: SharedPtr<PatchModel> _patch; bool _replace; + + Glib::RefPtr<Gtk::TreeSelection> _selection; + Glib::RefPtr<Gtk::ListStore> _liststore; + PatchColumns _columns; - Gtk::Entry* _uri_entry; - Gtk::Button* _open_button; - Gtk::Button* _cancel_button; + Gtk::TreeView* _treeview; + Gtk::Entry* _uri_entry; + Gtk::Button* _open_button; + Gtk::Button* _cancel_button; }; diff --git a/src/progs/ingenuity/ingenuity.glade b/src/progs/ingenuity/ingenuity.glade index 35d996e0..6d06f738 100644 --- a/src/progs/ingenuity/ingenuity.glade +++ b/src/progs/ingenuity/ingenuity.glade @@ -734,6 +734,7 @@ <child> <widget class="GtkButton" id="load_plugin_add_button"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="tooltip" translatable="yes">Add selected plugin to patch</property> <property name="can_focus">True</property> <property name="label">gtk-add</property> @@ -3990,7 +3991,7 @@ Contributors: <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> - <property name="resizable">False</property> + <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <property name="decorated">True</property> <property name="skip_taskbar_hint">False</property> @@ -4028,6 +4029,7 @@ Contributors: <child> <widget class="GtkButton" id="load_remote_patch_open_button"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can_default">True</property> <property name="has_default">True</property> <property name="can_focus">True</property> @@ -4048,48 +4050,92 @@ Contributors: </child> <child> - <widget class="GtkHBox" id="hbox71"> + <widget class="GtkVBox" id="vbox21"> <property name="visible">True</property> <property name="homogeneous">False</property> - <property name="spacing">0</property> + <property name="spacing">8</property> <child> - <widget class="GtkLabel" id="label133"> + <widget class="GtkScrolledWindow" id="load_remote_patch_treeview_sw"> <property name="visible">True</property> - <property name="label" translatable="yes">URI: </property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> + <property name="can_focus">True</property> + <property name="has_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="load_remote_patch_treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">True</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + </widget> + </child> </widget> <packing> <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> + <property name="expand">True</property> + <property name="fill">True</property> </packing> </child> <child> - <widget class="GtkEntry" id="load_remote_patch_uri_entry"> + <widget class="GtkHBox" id="hbox71"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char">*</property> - <property name="activates_default">False</property> - <property name="width_chars">78</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label133"> + <property name="visible">True</property> + <property name="label" translatable="yes">URI: </property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="load_remote_patch_uri_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + <property name="width_chars">78</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> </widget> <packing> <property name="padding">0</property> |