diff options
author | Robin Gareus <robin@gareus.org> | 2014-02-27 01:35:57 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-02-28 00:05:47 +0100 |
commit | 3cf5dcb64cc1f7d552bc22c5564896c1fbf3d2d0 (patch) | |
tree | 5774288210c70ec2c52db1dd973f79da47025252 | |
parent | f8ec1d1f27c08c6d186f048f73630ca8ce25574a (diff) |
move Paths Dialog to libgtkmm2ext
-rw-r--r-- | gtk2_ardour/rc_option_editor.cc | 14 | ||||
-rw-r--r-- | gtk2_ardour/wscript | 1 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/paths_dialog.h (renamed from gtk2_ardour/paths_dialog.h) | 18 | ||||
-rw-r--r-- | libs/gtkmm2ext/paths_dialog.cc (renamed from gtk2_ardour/paths_dialog.cc) | 47 | ||||
-rw-r--r-- | libs/gtkmm2ext/wscript | 1 | ||||
-rw-r--r-- | libs/pbd/pathexpand.cc | 30 | ||||
-rw-r--r-- | libs/pbd/pbd/pathexpand.h | 2 |
7 files changed, 54 insertions, 59 deletions
diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index d033bfdaf4..b3f95f4547 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -30,6 +30,7 @@ #include <gtkmm2ext/utils.h> #include <gtkmm2ext/slider_controller.h> #include <gtkmm2ext/gtk_ui.h> +#include <gtkmm2ext/paths_dialog.h> #include "pbd/fpu.h" #include "pbd/cpus.h" @@ -47,7 +48,6 @@ #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" @@ -997,9 +997,8 @@ private: class PluginOptions : public OptionEditorBox { public: - PluginOptions (Session *s, RCConfiguration* c) + PluginOptions (RCConfiguration* c) : _rc_config (c) - , _session(s) , _display_plugin_scan_progress (_("Display Plugin Scan Progress")) , _discover_vst_on_start (_("Scan for new VST Plugins on Application Start")) { @@ -1081,7 +1080,6 @@ public: private: RCConfiguration* _rc_config; - Session* _session; CheckButton _display_plugin_scan_progress; CheckButton _discover_vst_on_start; @@ -1104,7 +1102,8 @@ private: } void edit_vst_path_clicked () { - PathsDialog *pd = new PathsDialog(_session, + Gtkmm2ext::PathsDialog *pd = new Gtkmm2ext::PathsDialog ( + _("Set Windows VST Search Path"), _rc_config->get_plugin_path_vst(), PluginManager::instance().get_windows_vst_path() ); @@ -1118,7 +1117,8 @@ private: // todo consolidate with edit_vst_path_clicked.. void edit_lxvst_path_clicked () { - PathsDialog *pd = new PathsDialog(_session, + Gtkmm2ext::PathsDialog *pd = new Gtkmm2ext::PathsDialog ( + _("Set Linux VST Search Path"), _rc_config->get_plugin_path_lxvst(), PluginManager::instance().get_lxvst_path() ); @@ -2074,7 +2074,7 @@ RCOptionEditor::RCOptionEditor () #if (defined WINDOWS_VST_SUPPORT || defined LXVST_SUPPORT) /* Plugin options (currrently VST only) */ - add_option (_("Plugins"), new PluginOptions (_session, _rc_config)); + add_option (_("Plugins"), new PluginOptions (_rc_config)); #endif /* INTERFACE */ diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 24e40ea64a..24349d928d 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -159,7 +159,6 @@ gtk2_ardour_sources = [ 'panner_interface.cc', 'panner_ui.cc', 'patch_change.cc', - 'paths_dialog.cc', 'piano_roll_header.cc', 'pingback.cc', 'playlist_selector.cc', diff --git a/gtk2_ardour/paths_dialog.h b/libs/gtkmm2ext/gtkmm2ext/paths_dialog.h index 60776e2bf7..dd68a37bd9 100644 --- a/gtk2_ardour/paths_dialog.h +++ b/libs/gtkmm2ext/gtkmm2ext/paths_dialog.h @@ -16,19 +16,19 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef __gtk_ardour_paths_dialog_h__ -#define __gtk_ardour_paths_dialog_h__ +#ifndef __gtkmmext_paths_dialog_h__ +#define __gtkmmext_paths_dialog_h__ #include <string> #include <vector> #include <gtkmm.h> -#include "ardour_dialog.h" +namespace Gtkmm2ext { -class PathsDialog : public ArdourDialog +class PathsDialog : public Gtk::Dialog { public: - PathsDialog (ARDOUR::Session*, std::string, std::string); + PathsDialog (std::string, std::string, std::string); ~PathsDialog (); std::string get_serialized_paths (bool include_fixed = false); @@ -44,10 +44,8 @@ class PathsDialog : public ArdourDialog 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__ */ +} /* namespace */ + +#endif /* __gtkmmext_paths_dialog_h__ */ diff --git a/gtk2_ardour/paths_dialog.cc b/libs/gtkmm2ext/paths_dialog.cc index b83706ef37..7b42a85f32 100644 --- a/gtk2_ardour/paths_dialog.cc +++ b/libs/gtkmm2ext/paths_dialog.cc @@ -18,24 +18,20 @@ */ #include <cstdio> -#include "pbd/tokenizer.h" -#include "ardour/session.h" - -#include "ardour_ui.h" #include "i18n.h" -#include "paths_dialog.h" +#include "pbd/pathexpand.h" +#include "gtkmm2ext/paths_dialog.h" using namespace Gtk; using namespace std; -using namespace ARDOUR; +using namespace Gtkmm2ext; -PathsDialog::PathsDialog (Session* s, std::string user_paths, std::string fixed_paths) - : ArdourDialog (_("Set Paths"), true) +PathsDialog::PathsDialog (std::string title, std::string user_paths, std::string fixed_paths) + : Dialog (title, 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); @@ -43,9 +39,6 @@ PathsDialog::PathsDialog (Session* s, std::string user_paths, std::string fixed_ 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); @@ -54,12 +47,12 @@ PathsDialog::PathsDialog (Session* s, std::string user_paths, std::string fixed_ paths_list_view.set_column_title(1,"Path"); /* TODO fill in Text View */ - std::vector <std::string> a = parse_path(user_paths); + std::vector <std::string> a = PBD::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); + a = PBD::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); @@ -150,29 +143,3 @@ PathsDialog::remove_path() { 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/libs/gtkmm2ext/wscript b/libs/gtkmm2ext/wscript index 48895a698c..6d9f1edbe8 100644 --- a/libs/gtkmm2ext/wscript +++ b/libs/gtkmm2ext/wscript @@ -46,6 +46,7 @@ gtkmm2ext_sources = [ 'idle_adjustment.cc', 'keyboard.cc', 'motionfeedback.cc', + 'paths_dialog.cc', 'persistent_tooltip.cc', 'prolooks_helpers.c', 'pixfader.cc', diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc index 3398bd1152..e9bef4c4aa 100644 --- a/libs/pbd/pathexpand.cc +++ b/libs/pbd/pathexpand.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Paul Davis + Copyright (C) 2013-2014 Paul Davis 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 @@ -25,10 +25,12 @@ #include <regex.h> +#include <glibmm/fileutils.h> #include <glibmm/miscutils.h> #include "pbd/pathexpand.h" #include "pbd/strsplit.h" +#include "pbd/tokenizer.h" using std::string; using std::vector; @@ -192,3 +194,29 @@ PBD::search_path_expand (string path) return r; } + +std::vector <std::string> +PBD::parse_path(std::string path, bool check_if_exists) +{ + 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/libs/pbd/pbd/pathexpand.h b/libs/pbd/pbd/pathexpand.h index 5c5d4cf772..b7a0779d5e 100644 --- a/libs/pbd/pbd/pathexpand.h +++ b/libs/pbd/pbd/pathexpand.h @@ -20,6 +20,7 @@ #define __libpbd_path_expand_h__ #include <string> +#include <vector> #include "pbd/libpbd_visibility.h" @@ -27,6 +28,7 @@ namespace PBD { LIBPBD_API std::string canonical_path (const std::string& path); LIBPBD_API std::string path_expand (std::string path); LIBPBD_API std::string search_path_expand (std::string path); + LIBPBD_API std::vector<std::string> parse_path(std::string path, bool check_if_exists = false); } #endif /* __libpbd_path_expand_h__ */ |