From 533402f16f6a7e6a9aa6df4186055690bce8e3ac Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 12 Apr 2007 01:50:59 +0000 Subject: Updated Raptor dependency to 1.4.14 (for Turtle serialization). Made patches serialize to Turtle instead of RDF/XML because a) it's pretty and b) I said so. Loading of patches directly from the 'net in Ingenuity (File->Import Location). git-svn-id: http://svn.drobilla.net/lad/ingen@444 a436a847-0d15-0410-975c-d299462d15a1 --- configure.ac | 2 +- src/libs/client/Loader.cpp | 16 ++-- src/libs/client/Loader.h | 2 +- src/progs/ingenuity/LoadPatchWindow.cpp | 6 +- src/progs/ingenuity/LoadRemotePatchWindow.cpp | 99 ++++++++++++++++++++ src/progs/ingenuity/LoadRemotePatchWindow.h | 66 ++++++++++++++ src/progs/ingenuity/LoadSubpatchWindow.cpp | 4 +- src/progs/ingenuity/Makefile.am | 2 + src/progs/ingenuity/PatchWindow.cpp | 14 ++- src/progs/ingenuity/PatchWindow.h | 2 + src/progs/ingenuity/WindowFactory.cpp | 24 ++++- src/progs/ingenuity/WindowFactory.h | 3 + src/progs/ingenuity/ingenuity.glade | 126 +++++++++++++++++++++++++- 13 files changed, 344 insertions(+), 22 deletions(-) create mode 100644 src/progs/ingenuity/LoadRemotePatchWindow.cpp create mode 100644 src/progs/ingenuity/LoadRemotePatchWindow.h diff --git a/configure.ac b/configure.ac index 46902161..6d80d412 100644 --- a/configure.ac +++ b/configure.ac @@ -314,7 +314,7 @@ if test "$build_console_clients" = "yes"; then PKG_CHECK_MODULES(GLIBMM, glibmm-2.4) # Check for raptor (for RDF serialization) - PKG_CHECK_MODULES(RAPTOR, raptor >= 0.21, build_raptor="yes", build_raptor="no") + PKG_CHECK_MODULES(RAPTOR, raptor >= 1.4.14, build_raptor="yes", build_raptor="no") # Check for rasqal (for RDF querying) PKG_CHECK_MODULES(RASQAL, rasqal >= 0.9.11, build_rasqal="yes", build_rasqal="no") diff --git a/src/libs/client/Loader.cpp b/src/libs/client/Loader.cpp index 09724d6c..ed8d4497 100644 --- a/src/libs/client/Loader.cpp +++ b/src/libs/client/Loader.cpp @@ -44,12 +44,12 @@ Loader::Loader(SharedPtr engine, SharedPtr nam /** Load (create) all objects from an RDF into the engine. * - * @param filename Filename to load objects from. + * @param document_uri URI of file to load objects from. * @param parent Path of parent under which to load objects. * @return whether or not load was successful. */ bool -Loader::load(const Glib::ustring& filename, +Loader::load(const Glib::ustring& document_uri, boost::optional parent, string patch_name, Glib::ustring patch_uri, @@ -60,8 +60,8 @@ Loader::load(const Glib::ustring& filename, std::map created; // FIXME: kluge - unsigned char* document_uri_str = raptor_uri_filename_to_uri_string(filename.c_str()); - Glib::ustring document_uri = (const char*)document_uri_str; + //unsigned char* document_uri_str = raptor_uri_filename_to_uri_string(filename.c_str()); + //Glib::ustring document_uri = (const char*)document_uri_str; //Glib::ustring document_uri = "file:///home/dave/code/drobillanet/ingen/src/progs/ingenuity/test2.ingen.ttl"; patch_uri = string("<") + patch_uri + ">"; @@ -90,9 +90,9 @@ Loader::load(const Glib::ustring& filename, /* Get name (if available/necessary) */ if (patch_name == "") { - patch_name = string(filename.substr(filename.find_last_of("/")+1)); - if (patch_name.substr(patch_name.length()-6) == ".ingen") - patch_name = patch_name.substr(0, patch_name.length()-6); + patch_name = string(document_uri.substr(document_uri.find_last_of("/")+1)); + if (patch_name.substr(patch_name.length()-10) == ".ingen.ttl") + patch_name = patch_name.substr(0, patch_name.length()-10); query = RDFQuery(*_namespaces, Glib::ustring( "SELECT DISTINCT ?name FROM <") + document_uri + "> WHERE {\n" + @@ -165,7 +165,7 @@ Loader::load(const Glib::ustring& filename, const Path subpatch_path = patch_path.base() + (string)name; if (created.find(subpatch_path) == created.end()) { - load(filename, patch_path, name, patch); + load(document_uri, patch_path, name, patch); created[subpatch_path] = true; } } diff --git a/src/libs/client/Loader.h b/src/libs/client/Loader.h index 9afbace6..76a3e60c 100644 --- a/src/libs/client/Loader.h +++ b/src/libs/client/Loader.h @@ -39,7 +39,7 @@ class Loader { public: Loader(SharedPtr engine, SharedPtr = SharedPtr()); - bool load(const Glib::ustring& filename, + bool load(const Glib::ustring& uri, boost::optional parent, string patch_name, Glib::ustring patch_uri = "", diff --git a/src/progs/ingenuity/LoadPatchWindow.cpp b/src/progs/ingenuity/LoadPatchWindow.cpp index 783c6397..aba427e9 100644 --- a/src/progs/ingenuity/LoadPatchWindow.cpp +++ b/src/progs/ingenuity/LoadPatchWindow.cpp @@ -52,8 +52,8 @@ LoadPatchWindow::LoadPatchWindow(BaseObjectType* cobject, const Glib::RefPtrpath() != "/") parent = _patch->path().parent(); - App::instance().loader()->load_patch(true, get_filename(), "/", + App::instance().loader()->load_patch(true, get_uri(), "/", _initial_data, parent, name, poly); hide(); diff --git a/src/progs/ingenuity/LoadRemotePatchWindow.cpp b/src/progs/ingenuity/LoadRemotePatchWindow.cpp new file mode 100644 index 00000000..8f4fa3a2 --- /dev/null +++ b/src/progs/ingenuity/LoadRemotePatchWindow.cpp @@ -0,0 +1,99 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "LoadRemotePatchWindow.h" +#include +#include +#include +#include "App.h" +#include "Configuration.h" +#include "PatchModel.h" +#include "ModelEngineInterface.h" +#include "ThreadedLoader.h" + +using boost::optional; + +namespace Ingenuity { + + +LoadRemotePatchWindow::LoadRemotePatchWindow(BaseObjectType* cobject, const Glib::RefPtr& xml) +: Gtk::Dialog(cobject), + _replace(true) +{ + 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); + + _open_button->signal_clicked().connect(sigc::mem_fun(this, &LoadRemotePatchWindow::open_clicked)); + _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &LoadRemotePatchWindow::cancel_clicked)); +} + + +void +LoadRemotePatchWindow::present(SharedPtr patch, MetadataMap data) +{ + set_patch(patch); + _initial_data = data; + Gtk::Window::present(); +} + + +/** Sets the patch controller for this window and initializes everything. + * + * This function MUST be called before using the window in any way! + */ +void +LoadRemotePatchWindow::set_patch(SharedPtr patch) +{ + _patch = patch; +} + + +void +LoadRemotePatchWindow::open_clicked() +{ + Glib::ustring uri = _uri_entry->get_text(); + + cerr << "OPEN URI: " << uri << endl; + + // If unset load_patch will load values + optional name; + optional poly; + + optional parent; + + if (_replace) + App::instance().engine()->clear_patch(_patch->path()); + + if (_patch->path() != "/") + parent = _patch->path().parent(); + + App::instance().loader()->load_patch(true, uri, "/", + _initial_data, parent, name, poly); + + hide(); +} + + +void +LoadRemotePatchWindow::cancel_clicked() +{ + hide(); +} + + +} // namespace Ingenuity diff --git a/src/progs/ingenuity/LoadRemotePatchWindow.h b/src/progs/ingenuity/LoadRemotePatchWindow.h new file mode 100644 index 00000000..c7a8ee22 --- /dev/null +++ b/src/progs/ingenuity/LoadRemotePatchWindow.h @@ -0,0 +1,66 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LOADREMOTEPATCHWINDOW_H +#define LOADREMOTEPATCHWINDOW_H + +#include "PluginModel.h" + +#include +#include +#include "raul/SharedPtr.h" +#include "PatchModel.h" +using Ingen::Client::PatchModel; +using Ingen::Client::MetadataMap; + +namespace Ingenuity { + + +/* Load remote patch ("import location") dialog. + * + * \ingroup Ingenuity + */ +class LoadRemotePatchWindow : public Gtk::Dialog +{ +public: + LoadRemotePatchWindow(BaseObjectType* cobject, const Glib::RefPtr& xml); + + void set_patch(SharedPtr patch); + + void set_replace() { _replace = true; } + void set_merge() { _replace = false; } + + void present(SharedPtr patch, MetadataMap data); + +private: + void open_clicked(); + void cancel_clicked(); + + MetadataMap _initial_data; + + SharedPtr _patch; + bool _replace; + + Gtk::Entry* _uri_entry; + Gtk::Button* _open_button; + Gtk::Button* _cancel_button; +}; + + +} // namespace Ingenuity + +#endif // LOADREMOTEPATCHWINDOW_H diff --git a/src/progs/ingenuity/LoadSubpatchWindow.cpp b/src/progs/ingenuity/LoadSubpatchWindow.cpp index 7d3a252c..22beb70f 100644 --- a/src/progs/ingenuity/LoadSubpatchWindow.cpp +++ b/src/progs/ingenuity/LoadSubpatchWindow.cpp @@ -56,8 +56,8 @@ LoadSubpatchWindow::LoadSubpatchWindow(BaseObjectType* cobject, const Glib::RefP Gtk::FileFilter filt; filt.add_pattern("*.om"); filt.set_name("Om patch files (XML, DEPRECATED) (*.om)"); - filt.add_pattern("*.ingen"); - filt.set_name("Ingen patch files (RDF, *.ingen)"); + filt.add_pattern("*.ingen.ttl"); + filt.set_name("Ingen patch files (RDF, *.ingen.ttl)"); set_filter(filt); // Add global examples directory to "shortcut folders" (bookmarks) diff --git a/src/progs/ingenuity/Makefile.am b/src/progs/ingenuity/Makefile.am index 98dff1f4..91066d8e 100644 --- a/src/progs/ingenuity/Makefile.am +++ b/src/progs/ingenuity/Makefile.am @@ -47,6 +47,8 @@ ingenuity_SOURCES = \ LoadPluginWindow.cpp \ LoadPatchWindow.h \ LoadPatchWindow.cpp \ + LoadRemotePatchWindow.h \ + LoadRemotePatchWindow.cpp \ MessagesWindow.h \ MessagesWindow.cpp \ LoadSubpatchWindow.h \ diff --git a/src/progs/ingenuity/PatchWindow.cpp b/src/progs/ingenuity/PatchWindow.cpp index ddcccf10..d9677317 100644 --- a/src/progs/ingenuity/PatchWindow.cpp +++ b/src/progs/ingenuity/PatchWindow.cpp @@ -57,6 +57,7 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("patch_win_status_bar", _status_bar); //xml->get_widget("patch_open_menuitem", _menu_open); xml->get_widget("patch_import_menuitem", _menu_import); + xml->get_widget("patch_import_location_menuitem", _menu_import_location); //xml->get_widget("patch_open_into_menuitem", _menu_open_into); xml->get_widget("patch_save_menuitem", _menu_save); xml->get_widget("patch_save_as_menuitem", _menu_save_as); @@ -86,6 +87,8 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtrsignal_activate().connect( sigc::mem_fun(this, &PatchWindow::event_import)); + _menu_import_location->signal_activate().connect( + sigc::mem_fun(this, &PatchWindow::event_import_location)); _menu_save->signal_activate().connect( sigc::mem_fun(this, &PatchWindow::event_save)); _menu_save_as->signal_activate().connect( @@ -252,6 +255,13 @@ PatchWindow::event_import() } +void +PatchWindow::event_import_location() +{ + App::instance().window_factory()->present_load_remote_patch(_patch); +} + + void PatchWindow::event_save() { @@ -294,8 +304,8 @@ PatchWindow::event_save_as() if (result == Gtk::RESPONSE_OK) { string filename = dialog.get_filename(); - if (filename.length() < 7 || filename.substr(filename.length()-6) != ".ingen") - filename += ".ingen"; + if (filename.length() < 11 || filename.substr(filename.length()-10) != ".ingen.ttl") + filename += ".ingen.ttl"; bool confirm = false; std::fstream fin; diff --git a/src/progs/ingenuity/PatchWindow.h b/src/progs/ingenuity/PatchWindow.h index 6fbd9cce..e6131581 100644 --- a/src/progs/ingenuity/PatchWindow.h +++ b/src/progs/ingenuity/PatchWindow.h @@ -79,6 +79,7 @@ protected: private: void event_import(); + void event_import_location(); void event_save(); void event_save_as(); void event_copy(); @@ -101,6 +102,7 @@ private: int _y; Gtk::MenuItem* _menu_import; + Gtk::MenuItem* _menu_import_location; Gtk::MenuItem* _menu_save; Gtk::MenuItem* _menu_save_as; Gtk::MenuItem* _menu_cut; diff --git a/src/progs/ingenuity/WindowFactory.cpp b/src/progs/ingenuity/WindowFactory.cpp index ef4cb6af..3b773227 100644 --- a/src/progs/ingenuity/WindowFactory.cpp +++ b/src/progs/ingenuity/WindowFactory.cpp @@ -24,6 +24,7 @@ #include "NodeControlWindow.h" #include "LoadPluginWindow.h" #include "LoadPatchWindow.h" +#include "LoadRemotePatchWindow.h" #include "LoadSubpatchWindow.h" #include "RenameWindow.h" #include "NewSubpatchWindow.h" @@ -34,6 +35,7 @@ namespace Ingenuity { WindowFactory::WindowFactory() : _load_plugin_win(NULL) , _load_patch_win(NULL) +, _load_remote_patch_win(NULL) , _new_subpatch_win(NULL) , _load_subpatch_win(NULL) , _node_properties_win(NULL) @@ -41,13 +43,13 @@ WindowFactory::WindowFactory() { Glib::RefPtr xml = GladeFactory::new_glade_reference(); - xml->get_widget_derived("load_plugin_win", _load_plugin_win); - xml->get_widget_derived("load_patch_win", _load_patch_win); - xml->get_widget_derived("new_subpatch_win", _new_subpatch_win); + xml->get_widget_derived("load_plugin_win", _load_plugin_win); + xml->get_widget_derived("load_patch_win", _load_patch_win); + xml->get_widget_derived("load_remote_patch_win", _load_remote_patch_win); + xml->get_widget_derived("new_subpatch_win", _new_subpatch_win); xml->get_widget_derived("load_subpatch_win", _load_subpatch_win); xml->get_widget_derived("node_properties_win", _node_properties_win); xml->get_widget_derived("patch_properties_win", _patch_properties_win); - } @@ -261,6 +263,20 @@ WindowFactory::present_load_patch(SharedPtr patch, MetadataMap data) _load_patch_win->present(patch, data); } + +void +WindowFactory::present_load_remote_patch(SharedPtr patch, MetadataMap data) +{ + PatchWindowMap::iterator w = _patch_windows.find(patch->path()); + + if (w != _patch_windows.end()) + _load_remote_patch_win->set_transient_for(*w->second); + + _load_remote_patch_win->set_merge(); // Import is the only choice + + _load_remote_patch_win->present(patch, data); +} + void WindowFactory::present_new_subpatch(SharedPtr patch, MetadataMap data) diff --git a/src/progs/ingenuity/WindowFactory.h b/src/progs/ingenuity/WindowFactory.h index ad7fab6b..8bc22ff5 100644 --- a/src/progs/ingenuity/WindowFactory.h +++ b/src/progs/ingenuity/WindowFactory.h @@ -32,6 +32,7 @@ class NodeControlWindow; class NodePropertiesWindow; class PatchPropertiesWindow; class LoadPatchWindow; +class LoadRemotePatchWindow; class RenameWindow; @@ -59,6 +60,7 @@ public: void present_load_plugin(SharedPtr patch, MetadataMap data = MetadataMap()); void present_load_patch(SharedPtr patch, MetadataMap data = MetadataMap()); + void present_load_remote_patch(SharedPtr patch, MetadataMap data = MetadataMap()); void present_new_subpatch(SharedPtr patch, MetadataMap data = MetadataMap()); void present_load_subpatch(SharedPtr patch, MetadataMap data = MetadataMap()); void present_rename(SharedPtr object); @@ -83,6 +85,7 @@ private: LoadPluginWindow* _load_plugin_win; LoadPatchWindow* _load_patch_win; + LoadRemotePatchWindow* _load_remote_patch_win; NewSubpatchWindow* _new_subpatch_win; LoadSubpatchWindow* _load_subpatch_win; NodePropertiesWindow* _node_properties_win; diff --git a/src/progs/ingenuity/ingenuity.glade b/src/progs/ingenuity/ingenuity.glade index 09cb9788..35d996e0 100644 --- a/src/progs/ingenuity/ingenuity.glade +++ b/src/progs/ingenuity/ingenuity.glade @@ -66,7 +66,7 @@ - + True Import a patch from a URI Import _Location... @@ -3984,4 +3984,128 @@ Contributors: + + 8 + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + True + + + + True + False + 8 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + True + gtk-open + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + False + 0 + + + + True + URI: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + True + True + True + 0 + + True + * + False + 78 + + + 0 + True + True + + + + + 0 + True + True + + + + + + -- cgit v1.2.1