summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2013-03-21 21:33:02 +0100
committerRobin Gareus <robin@gareus.org>2013-03-21 21:33:02 +0100
commit268553ecd471e31d0a1a3976f02389260130e41d (patch)
treee66d6775992b8dfb39361550dde915a7b80d7b58
parentd99b5dfa37c7248e24a0266188752dfa6c9bb3f6 (diff)
honor CTRL modifier when drag/drop importing files (copy vs embed)
-rw-r--r--gtk2_ardour/editor.h4
-rw-r--r--gtk2_ardour/editor_canvas.cc15
-rw-r--r--gtk2_ardour/editor_canvas_events.cc16
-rw-r--r--gtk2_ardour/editor_regions.cc4
4 files changed, 29 insertions, 10 deletions
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 081d6d5c3c..b082a80f21 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1257,8 +1257,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void bring_in_external_audio (Editing::ImportMode mode, framepos_t& pos);
- bool idle_drop_paths (std::vector<std::string> paths, framepos_t frame, double ypos);
- void drop_paths_part_two (const std::vector<std::string>& paths, framepos_t frame, double ypos);
+ bool idle_drop_paths (std::vector<std::string> paths, framepos_t frame, double ypos, bool copy);
+ void drop_paths_part_two (const std::vector<std::string>& paths, framepos_t frame, double ypos, bool copy);
int import_sndfiles (std::vector<std::string> paths, Editing::ImportMode mode, ARDOUR::SrcQuality, framepos_t& pos,
int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool);
diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc
index 383241aec0..8c9970275d 100644
--- a/gtk2_ardour/editor_canvas.cc
+++ b/gtk2_ardour/editor_canvas.cc
@@ -412,14 +412,14 @@ Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context
}
bool
-Editor::idle_drop_paths (vector<string> paths, framepos_t frame, double ypos)
+Editor::idle_drop_paths (vector<string> paths, framepos_t frame, double ypos, bool copy)
{
- drop_paths_part_two (paths, frame, ypos);
+ drop_paths_part_two (paths, frame, ypos, copy);
return false;
}
void
-Editor::drop_paths_part_two (const vector<string>& paths, framepos_t frame, double ypos)
+Editor::drop_paths_part_two (const vector<string>& paths, framepos_t frame, double ypos, bool copy)
{
RouteTimeAxisView* tv;
@@ -430,7 +430,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, framepos_t frame, doub
frame = 0;
- if (Profile->get_sae() || Config->get_only_copy_imported_files()) {
+ if (Profile->get_sae() || Config->get_only_copy_imported_files() || copy) {
do_import (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, SrcBest, frame);
} else {
do_embed (paths, Editing::ImportDistinctFiles, ImportAsTrack, frame);
@@ -444,7 +444,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, framepos_t frame, doub
/* select the track, then embed/import */
selection->set (tv);
- if (Profile->get_sae() || Config->get_only_copy_imported_files()) {
+ if (Profile->get_sae() || Config->get_only_copy_imported_files() || copy) {
do_import (paths, Editing::ImportSerializeFiles, Editing::ImportToTrack, SrcBest, frame);
} else {
do_embed (paths, Editing::ImportSerializeFiles, ImportToTrack, frame);
@@ -481,14 +481,15 @@ Editor::drop_paths (const RefPtr<Gdk::DragContext>& context,
snap_to (frame);
+ bool copy = ((context->get_actions() & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY);
#ifdef GTKOSX
/* We are not allowed to call recursive main event loops from within
the main event loop with GTK/Quartz. Since import/embed wants
to push up a progress dialog, defer all this till we go idle.
*/
- Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &Editor::idle_drop_paths), paths, frame, cy));
+ Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &Editor::idle_drop_paths), paths, frame, cy, copy));
#else
- drop_paths_part_two (paths, frame, cy);
+ drop_paths_part_two (paths, frame, cy, copy);
#endif
}
diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc
index 631137fd2f..7cd25ca92c 100644
--- a/gtk2_ardour/editor_canvas_events.cc
+++ b/gtk2_ardour/editor_canvas_events.cc
@@ -26,6 +26,7 @@
#include "ardour/midi_region.h"
#include "ardour/region_factory.h"
+#include "ardour/profile.h"
#include "editor.h"
#include "keyboard.h"
@@ -1054,6 +1055,21 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
context->drag_status (context->get_suggested_action(), time);
return true;
}
+ } else {
+ /* DND originating from outside ardour
+ *
+ * TODO: check if file is audio/midi, allow drops on same track-type only,
+ * currently: if audio is dropped on a midi-track, it is only added to the region-list
+ */
+ if (Profile->get_sae() || Config->get_only_copy_imported_files()) {
+ context->drag_status(Gdk::ACTION_COPY, time);
+ } else {
+ if ((context->get_actions() & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY)
+ context->drag_status(Gdk::ACTION_COPY, time);
+ else
+ context->drag_status(Gdk::ACTION_LINK, time);
+ }
+ return true;
}
}
}
diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc
index 16c401b90e..ad5263d1d1 100644
--- a/gtk2_ardour/editor_regions.cc
+++ b/gtk2_ardour/editor_regions.cc
@@ -1233,7 +1233,9 @@ EditorRegions::drag_data_received (const RefPtr<Gdk::DragContext>& context,
if (_editor->convert_drop_to_paths (paths, context, x, y, data, info, time) == 0) {
framepos_t pos = 0;
- if (Profile->get_sae() || Config->get_only_copy_imported_files()) {
+ bool copy = ((context->get_actions() & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY);
+
+ if (Profile->get_sae() || Config->get_only_copy_imported_files() || copy) {
_editor->do_import (paths, Editing::ImportDistinctFiles, Editing::ImportAsRegion, SrcBest, pos);
} else {
_editor->do_embed (paths, Editing::ImportDistinctFiles, ImportAsRegion, pos);