move Paths Dialog to libgtkmm2ext

This commit is contained in:
Robin Gareus 2014-02-27 01:35:57 +01:00
parent f8ec1d1f27
commit 3cf5dcb64c
7 changed files with 54 additions and 59 deletions

View file

@ -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 */

View file

@ -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',

View file

@ -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__ */

View file

@ -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;
}

View file

@ -46,6 +46,7 @@ gtkmm2ext_sources = [
'idle_adjustment.cc',
'keyboard.cc',
'motionfeedback.cc',
'paths_dialog.cc',
'persistent_tooltip.cc',
'prolooks_helpers.c',
'pixfader.cc',

View file

@ -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;
}

View file

@ -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__ */