summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-04-14 11:55:39 +0200
committerRobin Gareus <robin@gareus.org>2015-04-14 12:09:45 +0200
commit2d8aa1d2fff149223d7e30ba23d73e6da4738f8c (patch)
tree4f1a447a8b285f48a15ae068e7bcfee7e8f3e82b
parentedb9a24727e27b9873cbb06ebc72d94381f41ea9 (diff)
simplify coaxing clock value out of ardour
-rw-r--r--gtk2_ardour/audio_clock.cc20
-rw-r--r--gtk2_ardour/audio_clock.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc
index 15fd85c229..a90946f3ba 100644
--- a/gtk2_ardour/audio_clock.cc
+++ b/gtk2_ardour/audio_clock.cc
@@ -2080,6 +2080,24 @@ AudioClock::frames_from_audioframes_string (const string& str) const
}
void
+AudioClock::copy_text_to_clipboard () const
+{
+ string val;
+ if (editing) {
+ val = pre_edit_string;
+ } else {
+ val = _layout->get_text ();
+ }
+ const size_t trim = val.find_first_not_of(" ");
+ if (trim == string::npos) {
+ assert(0); // empty clock, can't be right.
+ return;
+ }
+ Glib::RefPtr<Clipboard> cl = Gtk::Clipboard::get();
+ cl->set_text (val.substr(trim));
+}
+
+void
AudioClock::build_ops_menu ()
{
using namespace Menu_Helpers;
@@ -2099,6 +2117,8 @@ AudioClock::build_ops_menu ()
ops_items.push_back (MenuElem (_("Set From Playhead"), sigc::mem_fun(*this, &AudioClock::set_from_playhead)));
ops_items.push_back (MenuElem (_("Locate to This Time"), sigc::mem_fun(*this, &AudioClock::locate)));
}
+ ops_items.push_back (SeparatorElem());
+ ops_items.push_back (MenuElem (_("Copy to clipboard"), sigc::mem_fun(*this, &AudioClock::copy_text_to_clipboard)));
}
void
diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h
index 83bc3233c2..5ab75c261f 100644
--- a/gtk2_ardour/audio_clock.h
+++ b/gtk2_ardour/audio_clock.h
@@ -70,6 +70,8 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
void set_bbt_reference (framepos_t);
void set_is_duration (bool);
+ void copy_text_to_clipboard () const;
+
std::string name() const { return _name; }
framepos_t current_time (framepos_t position = 0) const;