summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/paths_dialog.cc178
-rw-r--r--gtk2_ardour/paths_dialog.h53
-rw-r--r--gtk2_ardour/rc_option_editor.cc82
-rw-r--r--gtk2_ardour/wscript1
4 files changed, 303 insertions, 11 deletions
diff --git a/gtk2_ardour/paths_dialog.cc b/gtk2_ardour/paths_dialog.cc
new file mode 100644
index 0000000000..b83706ef37
--- /dev/null
+++ b/gtk2_ardour/paths_dialog.cc
@@ -0,0 +1,178 @@
+/*
+ Copyright (C) 2014 Robin Gareus <robin@gareus.org>
+
+ This program 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.
+
+ This program 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 more 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+#include <cstdio>
+
+#include "pbd/tokenizer.h"
+#include "ardour/session.h"
+
+#include "ardour_ui.h"
+#include "i18n.h"
+#include "paths_dialog.h"
+
+using namespace Gtk;
+using namespace std;
+using namespace ARDOUR;
+
+PathsDialog::PathsDialog (Session* s, std::string user_paths, std::string fixed_paths)
+ : ArdourDialog (_("Set Paths"), true)
+ , paths_list_view(2, false, Gtk::SELECTION_SINGLE)
+ , add_path_button(_("Add"))
+ , remove_path_button(_("Delete"))
+{
+ set_session (s);
+ set_name ("PathsDialog");
+ set_skip_taskbar_hint (true);
+ set_resizable (true);
+ set_size_request (400, -1);
+
+ paths_list_view.set_border_width (4);
+
+ ARDOUR_UI::instance()->set_tip (add_path_button, _("Add a new search path"));
+ ARDOUR_UI::instance()->set_tip (remove_path_button, _("Remove selected search path"));
+
+ add_path_button.signal_clicked().connect (sigc::mem_fun (*this, &PathsDialog::add_path));
+ remove_path_button.signal_clicked().connect (sigc::mem_fun (*this, &PathsDialog::remove_path));
+ remove_path_button.set_sensitive(false);
+
+ paths_list_view.set_column_title(0,"Type");
+ paths_list_view.set_column_title(1,"Path");
+
+ /* TODO fill in Text View */
+ std::vector <std::string> a = parse_path(user_paths);
+ for(vector<std::string>::const_iterator i = a.begin(); i != a.end(); ++i) {
+ int row = paths_list_view.append(_("user"));
+ paths_list_view.set_text(row, 1, *i);
+ }
+ a = parse_path(fixed_paths);
+ for(vector<std::string>::const_iterator i = a.begin(); i != a.end(); ++i) {
+ int row = paths_list_view.append( _("sys"));
+ paths_list_view.set_text(row, 1, *i);
+ }
+
+ paths_list_view.get_selection()->signal_changed().connect (mem_fun (*this, &PathsDialog::selection_changed));
+
+ /* Overall layout */
+ HBox *hbox = manage (new HBox);
+ hbox->pack_start (paths_list_view, true, true);
+ get_vbox()->set_spacing (4);
+ get_vbox()->pack_start (*hbox, true, true);
+
+ add_button (Stock::CANCEL, RESPONSE_CANCEL);
+ add_button (Stock::OK, RESPONSE_ACCEPT);
+ get_action_area()->pack_start (add_path_button, false, false);
+ get_action_area()->pack_start (remove_path_button, false, false);
+
+ show_all_children ();
+}
+
+PathsDialog::~PathsDialog ()
+{
+}
+
+void
+PathsDialog::on_show() {
+ Dialog::on_show ();
+}
+
+std::string
+PathsDialog::get_serialized_paths(bool include_fixed) {
+ std::string path;
+ for (unsigned int i = 0; i < paths_list_view.size(); ++i) {
+ if (!include_fixed && paths_list_view.get_text(i, 0) != _("user")) continue;
+ if (i > 0) path += G_SEARCHPATH_SEPARATOR;
+ path += paths_list_view.get_text(i, 1);
+ }
+ return path;
+}
+
+void
+PathsDialog::selection_changed () {
+ std::vector<int> selection = paths_list_view.get_selected();
+ if (selection.size() > 0) {
+ const int row = selection.at(0);
+ if (paths_list_view.get_text(row, 0) == _("user")) {
+ remove_path_button.set_sensitive(true);
+ return;
+ }
+ }
+ remove_path_button.set_sensitive(false);
+}
+
+void
+PathsDialog::add_path() {
+ Gtk::FileChooserDialog d (_("Add folder to search path"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ d.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ d.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
+ ResponseType r = (ResponseType) d.run ();
+ if (r == Gtk::RESPONSE_OK) {
+ std::string dir = d.get_filename();
+ if (Glib::file_test (dir, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
+ paths_list_view.prepend(_("user"));
+ paths_list_view.set_text(0, 1, dir);
+ }
+ }
+}
+
+void
+PathsDialog::remove_path() {
+ std::vector<int> selection = paths_list_view.get_selected();
+ if (selection.size() != 1) { return ; }
+ const int row = selection.at(0);
+ if (paths_list_view.get_text(row, 0) != _("user")) { return ; }
+
+ /* Gtk::ListViewText internals to delete row(s) */
+ Gtk::TreeModel::iterator row_it = paths_list_view.get_selection()->get_selected();
+ Glib::RefPtr<Gtk::TreeModel> reftm = paths_list_view.get_model();
+ Glib::RefPtr<Gtk::TreeStore> refStore = Glib::RefPtr<Gtk::TreeStore>::cast_dynamic(reftm);
+ if(refStore) {
+ refStore->erase(row_it);
+ return;
+ }
+ Glib::RefPtr<Gtk::ListStore> refLStore = Glib::RefPtr<Gtk::ListStore>::cast_dynamic(reftm);
+ if(refLStore){
+ refLStore->erase(row_it);
+ return;
+ }
+}
+
+const std::vector <std::string>
+PathsDialog::parse_path(std::string path, bool check_if_exists) const
+{
+ vector <std::string> pathlist;
+ vector <std::string> tmp;
+ PBD::tokenize (path, string(G_SEARCHPATH_SEPARATOR_S), std::back_inserter (tmp));
+
+ for(vector<std::string>::const_iterator i = tmp.begin(); i != tmp.end(); ++i) {
+ if ((*i).empty()) continue;
+ std::string dir;
+#ifndef PLATFORM_WINDOWS
+ if ((*i).substr(0,1) == "~") {
+ dir = Glib::build_filename(Glib::get_home_dir(), (*i).substr(1));
+ }
+ else
+#endif
+ {
+ dir = *i;
+ }
+ if (!check_if_exists || Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
+ pathlist.push_back(dir);
+ }
+ }
+ return pathlist;
+}
diff --git a/gtk2_ardour/paths_dialog.h b/gtk2_ardour/paths_dialog.h
new file mode 100644
index 0000000000..60776e2bf7
--- /dev/null
+++ b/gtk2_ardour/paths_dialog.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2014 Robin Gareus <robin@gareus.org>
+
+ This program 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.
+
+ This program 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 more 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+#ifndef __gtk_ardour_paths_dialog_h__
+#define __gtk_ardour_paths_dialog_h__
+
+#include <string>
+#include <vector>
+#include <gtkmm.h>
+
+#include "ardour_dialog.h"
+
+class PathsDialog : public ArdourDialog
+{
+ public:
+ PathsDialog (ARDOUR::Session*, std::string, std::string);
+ ~PathsDialog ();
+
+ std::string get_serialized_paths (bool include_fixed = false);
+
+ private:
+ void on_show ();
+
+ Gtk::ListViewText paths_list_view;
+
+ Gtk::Button add_path_button;
+ Gtk::Button remove_path_button;
+
+ void selection_changed();
+ void add_path();
+ void remove_path();
+
+ // TODO move to PBD ?
+ const std::vector <std::string> parse_path(std::string path, bool check_if_exists = false) const;
+
+};
+
+#endif /* __gtk_ardour_paths_dialog_h__ */
diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc
index 0331597fac..d033bfdaf4 100644
--- a/gtk2_ardour/rc_option_editor.cc
+++ b/gtk2_ardour/rc_option_editor.cc
@@ -47,6 +47,7 @@
#include "ardour_dialog.h"
#include "gui_thread.h"
#include "midi_tracer.h"
+#include "paths_dialog.h"
#include "rc_option_editor.h"
#include "utils.h"
#include "midi_port_dialog.h"
@@ -996,37 +997,68 @@ private:
class PluginOptions : public OptionEditorBox
{
public:
- PluginOptions (RCConfiguration* c)
+ PluginOptions (Session *s, RCConfiguration* c)
: _rc_config (c)
+ , _session(s)
, _display_plugin_scan_progress (_("Display Plugin Scan Progress"))
- , _discover_vst_on_start (_("Scan for new VST Plugin on Application Start"))
+ , _discover_vst_on_start (_("Scan for new VST Plugins on Application Start"))
{
+ Label *l;
+ std::stringstream ss;
Table* t = manage (new Table (2, 6));
t->set_spacings (4);
Button* b;
+ int n = 0;
+
+ ss << "<b>" << _("General") << "</b>";
+ l = manage (left_aligned_label (ss.str()));
+ l->set_use_markup (true);
+ t->attach (*manage (new Label ("")), 0, 3, n, n+1, FILL | EXPAND); ++n;
+ t->attach (*l, 0, 2, n, n+1, FILL | EXPAND); ++n;
b = manage (new Button (_("Refresh Plugin List")));
b->signal_clicked().connect (sigc::mem_fun (*this, &PluginOptions::refresh_clicked));
- t->attach (*b, 0, 2, 0, 1, FILL);
+ t->attach (*b, 0, 2, n, n+1, FILL); ++n;
+
+ t->attach (_display_plugin_scan_progress, 0, 2, n, n+1); ++n;
+ _display_plugin_scan_progress.signal_toggled().connect (sigc::mem_fun (*this, &PluginOptions::display_plugin_scan_progress_toggled));
+ Gtkmm2ext::UI::instance()->set_tip (_display_plugin_scan_progress,
+ _("<b>When enabled</b> display a popup window showing plugin scan progress."));
+
+
+ ss << "<b>" << _("VST") << "</b>";
+ l = manage (left_aligned_label (ss.str()));
+ l->set_use_markup (true);
+ t->attach (*manage (new Label ("")), 0, 3, n, n+1, FILL | EXPAND); ++n;
+ t->attach (*l, 0, 2, n, n+1, FILL | EXPAND); ++n;
b = manage (new Button (_("Clear VST Cache")));
b->signal_clicked().connect (sigc::mem_fun (*this, &PluginOptions::clear_vst_cache_clicked));
- t->attach (*b, 0, 2, 1, 2, FILL);
+ t->attach (*b, 0, 1, n, n+1, FILL);
b = manage (new Button (_("Clear VST Blacklist")));
b->signal_clicked().connect (sigc::mem_fun (*this, &PluginOptions::clear_vst_blacklist_clicked));
- t->attach (*b, 0, 2, 2, 3, FILL);
+ t->attach (*b, 1, 2, n, n+1, FILL);
+ ++n;
- t->attach (_discover_vst_on_start, 0, 2, 3, 4);
+ t->attach (_discover_vst_on_start, 0, 2, n, n+1); ++n;
_discover_vst_on_start.signal_toggled().connect (sigc::mem_fun (*this, &PluginOptions::discover_vst_on_start_toggled));
Gtkmm2ext::UI::instance()->set_tip (_discover_vst_on_start,
_("<b>When enabled</b> VST plugins are searched and tested on application start. When disabled they a Refresh will have to be tiggered manually"));
- t->attach (_display_plugin_scan_progress, 0, 2, 4, 5);
- _display_plugin_scan_progress.signal_toggled().connect (sigc::mem_fun (*this, &PluginOptions::display_plugin_scan_progress_toggled));
- Gtkmm2ext::UI::instance()->set_tip (_display_plugin_scan_progress,
- _("<b>When enabled</b> display a popup window showing plugin scan progress."));
+#ifdef WINDOWS_VST_SUPPORT
+ t->attach (*manage (left_aligned_label (_("Windows VST Path:"))), 0, 1, n, n+1);
+ b = manage (new Button (_("Edit")));
+ b->signal_clicked().connect (sigc::mem_fun (*this, &PluginOptions::edit_vst_path_clicked));
+ t->attach (*b, 1, 2, n, n+1, FILL); ++n;
+#endif
+#ifdef LXVST_SUPPORT
+ t->attach (*manage (left_aligned_label (_("Linux VST:"))), 0, 1, n, n+1);
+ b = manage (new Button (_("Edit")));
+ b->signal_clicked().connect (sigc::mem_fun (*this, &PluginOptions::edit_lxvst_path_clicked));
+ t->attach (*b, 1, 2, n, n+1, FILL); ++n;
+#endif
_box->pack_start (*t,true,true);
}
@@ -1049,6 +1081,7 @@ public:
private:
RCConfiguration* _rc_config;
+ Session* _session;
CheckButton _display_plugin_scan_progress;
CheckButton _discover_vst_on_start;
@@ -1070,6 +1103,33 @@ private:
PluginManager::instance().clear_vst_blacklist();
}
+ void edit_vst_path_clicked () {
+ PathsDialog *pd = new PathsDialog(_session,
+ _rc_config->get_plugin_path_vst(),
+ PluginManager::instance().get_windows_vst_path()
+ );
+ ResponseType r = (ResponseType) pd->run ();
+ pd->hide();
+ if (r == RESPONSE_ACCEPT) {
+ _rc_config->set_plugin_path_vst(pd->get_serialized_paths());
+ }
+ delete pd;
+ }
+
+ // todo consolidate with edit_vst_path_clicked..
+ void edit_lxvst_path_clicked () {
+ PathsDialog *pd = new PathsDialog(_session,
+ _rc_config->get_plugin_path_lxvst(),
+ PluginManager::instance().get_lxvst_path()
+ );
+ ResponseType r = (ResponseType) pd->run ();
+ pd->hide();
+ if (r == RESPONSE_ACCEPT) {
+ printf("%s", pd->get_serialized_paths().c_str());
+ }
+ delete pd;
+ }
+
void refresh_clicked () {
PluginManager::instance().refresh();
}
@@ -2014,7 +2074,7 @@ RCOptionEditor::RCOptionEditor ()
#if (defined WINDOWS_VST_SUPPORT || defined LXVST_SUPPORT)
/* Plugin options (currrently VST only) */
- add_option (_("Plugin"), new PluginOptions (_rc_config));
+ add_option (_("Plugins"), new PluginOptions (_session, _rc_config));
#endif
/* INTERFACE */
diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript
index 24349d928d..24e40ea64a 100644
--- a/gtk2_ardour/wscript
+++ b/gtk2_ardour/wscript
@@ -159,6 +159,7 @@ gtk2_ardour_sources = [
'panner_interface.cc',
'panner_ui.cc',
'patch_change.cc',
+ 'paths_dialog.cc',
'piano_roll_header.cc',
'pingback.cc',
'playlist_selector.cc',