fix crash when copy'ing latent plugins
[ardour.git] / gtk2_ardour / insert_remove_time_dialog.cc
index 58345aed654f8cdf82593e9bdad259ba6b010186..0aeca1e2df37fc42f0b0e6b2b1756dcbfbcd6363 100644 (file)
@@ -23,7 +23,7 @@
 #include <gtkmm/alignment.h>
 #include "insert_remove_time_dialog.h"
 #include "audio_clock.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace Gtk;
 using namespace Editing;
@@ -31,7 +31,13 @@ using namespace Editing;
 InsertRemoveTimeDialog::InsertRemoveTimeDialog (PublicEditor& e, bool remove)
        : ArdourDialog (remove ? _("Remove Time") : _("Insert Time"))
        , _editor (e)
-       , _clock ("insertTimeClock", true, "", true, false, true, false)
+       , _clock ("insertTimeClock", true, "",
+                       true,   // editable
+                       false,  // follows_playhead
+                       true,   // duration
+                       false,  // with_info
+                       true    // accept_on_focus_out
+               )
 {
        set_session (_editor.session ());
 
@@ -90,7 +96,9 @@ InsertRemoveTimeDialog::InsertRemoveTimeDialog (PublicEditor& e, bool remove)
        get_vbox()->pack_start (*tempo_box);
 
        add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-       add_button (remove ? _("Cut time") : _("Insert time"), Gtk::RESPONSE_OK);
+       Gtk::Button *btn = manage (new Gtk::Button (remove ? _("Remove time") : _("Insert time")));
+       btn->signal_clicked().connect (sigc::mem_fun(*this, &InsertRemoveTimeDialog::doit));
+       get_action_area()->pack_start (*btn);
        show_all ();
 
        move_markers_toggled ();
@@ -159,6 +167,17 @@ InsertRemoveTimeDialog::distance () const
        return _clock.current_duration (_editor.get_preferred_edit_position ());
 }
 
+void
+InsertRemoveTimeDialog::doit ()
+{
+       if (distance () == 0) {
+               Gtk::MessageDialog msg (*this, _("Invalid or zero duration entered. Please enter a valid duration"));
+               msg.run ();
+               return;
+       }
+       response (RESPONSE_OK);
+}
+
 void
 InsertRemoveTimeDialog::move_markers_toggled ()
 {