mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-20 13:46:30 +01:00
support DnD in native/gtk-quartz implementation (note: multifile DnD requires a patch to GTK that is not in distribution yet, so for now, this works only with 1 file at a time, or it requires my patch/library).
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2319 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
f433b4e735
commit
327275f4c9
6 changed files with 105 additions and 11 deletions
|
|
@ -2695,6 +2695,8 @@ Editor::convert_drop_to_paths (vector<ustring>& paths,
|
||||||
|
|
||||||
vector<ustring> uris = data.get_uris();
|
vector<ustring> uris = data.get_uris();
|
||||||
|
|
||||||
|
cerr << "there were " << uris.size() << " in that drag data\n";
|
||||||
|
|
||||||
if (uris.empty()) {
|
if (uris.empty()) {
|
||||||
|
|
||||||
/* This is seriously fucked up. Nautilus doesn't say that its URI lists
|
/* This is seriously fucked up. Nautilus doesn't say that its URI lists
|
||||||
|
|
@ -2746,10 +2748,35 @@ Editor::convert_drop_to_paths (vector<ustring>& paths,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
|
for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
|
||||||
|
|
||||||
if ((*i).substr (0,7) == "file://") {
|
if ((*i).substr (0,7) == "file://") {
|
||||||
string p = *i;
|
|
||||||
|
|
||||||
|
ustring p = *i;
|
||||||
PBD::url_decode (p);
|
PBD::url_decode (p);
|
||||||
paths.push_back (p.substr (7));
|
|
||||||
|
// scan forward past three slashes
|
||||||
|
|
||||||
|
ustring::size_type slashcnt = 0;
|
||||||
|
ustring::size_type n = 0;
|
||||||
|
ustring::iterator x = p.begin();
|
||||||
|
|
||||||
|
while (slashcnt < 3 && x != p.end()) {
|
||||||
|
if ((*x) == '/') {
|
||||||
|
slashcnt++;
|
||||||
|
} else if (slashcnt == 3) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++n;
|
||||||
|
++x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slashcnt != 3 || x == p.end()) {
|
||||||
|
error << _("malformed URL passed to drag-n-drop code") << endmsg;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
paths.push_back (p.substr (n - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -964,7 +964,11 @@ class Editor : public PublicEditor
|
||||||
|
|
||||||
void bring_in_external_audio (Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes_t& pos, bool prompt);
|
void bring_in_external_audio (Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes_t& pos, bool prompt);
|
||||||
void do_import (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes_t&, bool);
|
void do_import (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes_t&, bool);
|
||||||
|
|
||||||
|
void _do_embed (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes_t&, bool);
|
||||||
void do_embed (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes_t&, bool);
|
void do_embed (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes_t&, bool);
|
||||||
|
bool idle_do_embed (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes_t&, bool);
|
||||||
|
|
||||||
int import_sndfile (vector<Glib::ustring> paths, Editing::ImportMode mode, ARDOUR::AudioTrack* track, nframes_t& pos);
|
int import_sndfile (vector<Glib::ustring> paths, Editing::ImportMode mode, ARDOUR::AudioTrack* track, nframes_t& pos);
|
||||||
int embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode,
|
int embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode,
|
||||||
ARDOUR::AudioTrack* track, nframes_t& pos, bool prompt);
|
ARDOUR::AudioTrack* track, nframes_t& pos, bool prompt);
|
||||||
|
|
|
||||||
|
|
@ -130,8 +130,25 @@ Editor::do_import (vector<ustring> paths, bool split, ImportMode mode, AudioTrac
|
||||||
interthread_progress_window->hide_all ();
|
interthread_progress_window->hide_all ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Editor::idle_do_embed (vector<ustring> paths, bool split, ImportMode mode, AudioTrack* track, nframes_t& pos, bool prompt)
|
||||||
|
{
|
||||||
|
_do_embed (paths, split, mode, track, pos, prompt);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Editor::do_embed (vector<ustring> paths, bool split, ImportMode mode, AudioTrack* track, nframes_t& pos, bool prompt)
|
Editor::do_embed (vector<ustring> paths, bool split, ImportMode mode, AudioTrack* track, nframes_t& pos, bool prompt)
|
||||||
|
{
|
||||||
|
#ifdef GTKOSX
|
||||||
|
Glib::signal_idle().connect (bind (mem_fun (*this, &Editor::idle_do_embed), paths, split, mode, track, pos, prompt));
|
||||||
|
#else
|
||||||
|
_do_embed (paths, split, mode, track, pos, prompt);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Editor::_do_embed (vector<ustring> paths, bool split, ImportMode mode, AudioTrack* track, nframes_t& pos, bool prompt)
|
||||||
{
|
{
|
||||||
bool multiple_files = paths.size() > 1;
|
bool multiple_files = paths.size() > 1;
|
||||||
bool check_sample_rate = true;
|
bool check_sample_rate = true;
|
||||||
|
|
@ -139,8 +156,6 @@ Editor::do_embed (vector<ustring> paths, bool split, ImportMode mode, AudioTrack
|
||||||
|
|
||||||
for (a = paths.begin(); a != paths.end(); ) {
|
for (a = paths.begin(); a != paths.end(); ) {
|
||||||
|
|
||||||
cerr << "Considering embed of " << (*a) << endl;
|
|
||||||
|
|
||||||
Glib::ustring path = *a;
|
Glib::ustring path = *a;
|
||||||
Glib::ustring pair_base;
|
Glib::ustring pair_base;
|
||||||
vector<ustring> to_embed;
|
vector<ustring> to_embed;
|
||||||
|
|
@ -321,7 +336,6 @@ Editor::embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_fi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* note that we temporarily truncated _id at the colon */
|
/* note that we temporarily truncated _id at the colon */
|
||||||
|
|
@ -329,7 +343,7 @@ Editor::embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_fi
|
||||||
string error_msg;
|
string error_msg;
|
||||||
|
|
||||||
if (!AudioFileSource::get_soundfile_info (path, finfo, error_msg)) {
|
if (!AudioFileSource::get_soundfile_info (path, finfo, error_msg)) {
|
||||||
error << string_compose(_("Editor: cannot open file \"%1\", (%2)"), selection, error_msg ) << endmsg;
|
error << string_compose(_("Editor: cannot open file \"%1\", (%2)"), path, error_msg ) << endmsg;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -388,7 +402,7 @@ Editor::embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_fi
|
||||||
}
|
}
|
||||||
|
|
||||||
track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
|
track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
|
||||||
ARDOUR_UI::instance()->flush_pending ();
|
// ARDOUR_UI::instance()->flush_pending ();
|
||||||
|
|
||||||
/* make the proper number of channels in the region */
|
/* make the proper number of channels in the region */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import glob
|
||||||
Import('env libraries install_prefix')
|
Import('env libraries install_prefix')
|
||||||
|
|
||||||
midi2 = env.Copy()
|
midi2 = env.Copy()
|
||||||
midi2.Merge([ libraries['sigc2'], libraries['xml'], libraries['glib2'], libraries['pbd'] ])
|
midi2.Merge([ libraries['sigc2'], libraries['xml'], libraries['glibmm2'], libraries['glib2'], libraries['pbd'] ])
|
||||||
|
|
||||||
domain = 'midipp'
|
domain = 'midipp'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
using Glib::ustring;
|
||||||
|
|
||||||
namespace PBD {
|
namespace PBD {
|
||||||
|
|
||||||
|
|
@ -196,6 +197,52 @@ url_decode (string& url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
url_decode (ustring& url)
|
||||||
|
{
|
||||||
|
ustring::iterator last;
|
||||||
|
ustring::iterator next;
|
||||||
|
|
||||||
|
for (ustring::iterator i = url.begin(); i != url.end(); ++i) {
|
||||||
|
if ((*i) == '+') {
|
||||||
|
next = i;
|
||||||
|
++next;
|
||||||
|
url.replace (i, next, 1, ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url.length() <= 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
last = url.end();
|
||||||
|
|
||||||
|
--last; /* points at last char */
|
||||||
|
--last; /* points at last char - 1 */
|
||||||
|
|
||||||
|
for (ustring::iterator i = url.begin(); i != last; ) {
|
||||||
|
|
||||||
|
if (*i == '%') {
|
||||||
|
|
||||||
|
next = i;
|
||||||
|
|
||||||
|
url.erase (i);
|
||||||
|
|
||||||
|
i = next;
|
||||||
|
++next;
|
||||||
|
|
||||||
|
if (isxdigit (*i) && isxdigit (*next)) {
|
||||||
|
/* replace first digit with char */
|
||||||
|
url.replace (i, next, 1, (gunichar) int_from_hex (*i,*next));
|
||||||
|
++i; /* points at 2nd of 2 digits */
|
||||||
|
url.erase (i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
string
|
string
|
||||||
length2string (const int32_t frames, const float sample_rate)
|
length2string (const int32_t frames, const float sample_rate)
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
namespace PBD {
|
namespace PBD {
|
||||||
|
|
||||||
|
|
@ -32,6 +33,7 @@ std::string short_version (std::string, std::string::size_type target_length);
|
||||||
int atoi (const std::string&);
|
int atoi (const std::string&);
|
||||||
double atof (const std::string&);
|
double atof (const std::string&);
|
||||||
void url_decode (std::string&);
|
void url_decode (std::string&);
|
||||||
|
void url_decode (Glib::ustring&);
|
||||||
|
|
||||||
// std::string length2string (const int32_t frames, const float sample_rate);
|
// std::string length2string (const int32_t frames, const float sample_rate);
|
||||||
std::string length2string (const int64_t frames, const double sample_rate);
|
std::string length2string (const int64_t frames, const double sample_rate);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue