new hellenic translation, plus new names in about dialog
[ardour.git] / gtk2_ardour / editor_timefx.cc
index 805c4e0b1daee20997e7526d10350dcde2f220c9..2efdc03f8fdca0c723997ea380732ed01ef2b7e8 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #include <cstdlib>
 
 #include <pbd/error.h>
 #include <pbd/pthread_utils.h>
+#include <pbd/memento_command.h>
+
+#include <gtkmm2ext/window_title.h>
 
 #include "editor.h"
 #include "audio_time_axis.h"
-#include "regionview.h"
+#include "audio_region_view.h"
 #include "region_selection.h"
 
 #include <ardour/session.h>
 #include <ardour/audioplaylist.h>
 #include <ardour/audio_track.h>
 #include <ardour/audioregion.h>
-#include <ardour/diskstream.h>
+#include <ardour/audio_diskstream.h>
 
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
+using namespace Gtkmm2ext;
 
 Editor::TimeStretchDialog::TimeStretchDialog (Editor& e)
        : ArdourDialog ("time stretch dialog"),
          editor (e),
          quick_button (_("Quick but Ugly")),
-         antialias_button (_("Skip Anti-aliasing")),
-         cancel_button (_("Cancel")),
-         action_button (_("Stretch/Shrink it"))
+         antialias_button (_("Skip Anti-aliasing"))
 {
        set_modal (true);
        set_position (Gtk::WIN_POS_MOUSE);
-       set_title (_("ardour: timestretch"));
        set_name (N_("TimeStretchDialog"));
 
-       set_hide_on_stop (false);
+       WindowTitle title(Glib::get_application_name());
+       title += _("Timestretch");
+       set_title(title.get_string());
 
-       add (packer);
+       get_vbox()->set_spacing (5);
+       get_vbox()->set_border_width (5);
+       get_vbox()->pack_start (upper_button_box);
+       get_vbox()->pack_start (progress_bar);
 
-       packer.set_spacing (5);
-       packer.set_border_width (5);
-       packer.pack_start (upper_button_box);
-       packer.pack_start (progress_bar);
-       packer.pack_start (lower_button_box);
-       
        upper_button_box.set_homogeneous (true);
        upper_button_box.set_spacing (5);
        upper_button_box.set_border_width (5);
        upper_button_box.pack_start (quick_button, true, true);
        upper_button_box.pack_start (antialias_button, true, true);
 
-       lower_button_box.set_homogeneous (true);
-       lower_button_box.set_spacing (5);
-       lower_button_box.set_border_width (5);
-       lower_button_box.pack_start (action_button, true, true);
-       lower_button_box.pack_start (cancel_button, true, true);
+       action_button = add_button (_("Stretch/Shrink it"), Gtk::RESPONSE_ACCEPT);
+       cancel_button = add_button (_("Cancel"), Gtk::RESPONSE_CANCEL);
 
-       action_button.set_name (N_("TimeStretchButton"));
-       cancel_button.set_name (N_("TimeStretchButton"));
        quick_button.set_name (N_("TimeStretchButton"));
        antialias_button.set_name (N_("TimeStretchButton"));
        progress_bar.set_name (N_("TimeStretchProgress"));
 
-       action_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), 1));
+       show_all_children ();
 }
 
 gint
 Editor::TimeStretchDialog::update_progress ()
 {
-       progress_bar.set_fraction (request.progress/100);
+       progress_bar.set_fraction (request.progress);
        return request.running;
 }
 
@@ -111,7 +106,7 @@ Editor::TimeStretchDialog::delete_timestretch_in_progress (GdkEventAny* ev)
 }
 
 int
-Editor::run_timestretch (AudioRegionSelection& regions, float fraction)
+Editor::run_timestretch (RegionSelection& regions, float fraction)
 {
        pthread_t thread;
 
@@ -120,16 +115,13 @@ Editor::run_timestretch (AudioRegionSelection& regions, float fraction)
        }
 
        current_timestretch->progress_bar.set_fraction (0.0f);
-       current_timestretch->first_cancel = current_timestretch->cancel_button.signal_clicked().connect (bind (mem_fun (*current_timestretch, &ArdourDialog::stop), -1));
-       // GTK2FIX
-       // current_timestretch->first_delete = current_timestretch->signal_delete_event().connect (mem_fun (*current_timestretch, &ArdourDialog::wm_close_event));
 
-       current_timestretch->run ();
-
-       if (current_timestretch->run_status() != 1) {
-               // GTK2FIX
-               // current_timestretch->close ();
-               return 1; /* no error, but we did nothing */
+       switch (current_timestretch->run ()) {
+       case RESPONSE_ACCEPT:
+               break;
+       default:
+               current_timestretch->hide ();
+               return 1;
        }
 
        current_timestretch->status = 0;
@@ -145,12 +137,11 @@ Editor::run_timestretch (AudioRegionSelection& regions, float fraction)
        current_timestretch->first_cancel.disconnect();
        current_timestretch->first_delete.disconnect();
        
-       current_timestretch->cancel_button.signal_clicked().connect (mem_fun (current_timestretch, &TimeStretchDialog::cancel_timestretch_in_progress));
+       current_timestretch->cancel_button->signal_clicked().connect (mem_fun (current_timestretch, &TimeStretchDialog::cancel_timestretch_in_progress));
        current_timestretch->signal_delete_event().connect (mem_fun (current_timestretch, &TimeStretchDialog::delete_timestretch_in_progress));
 
        if (pthread_create_and_store ("timestretch", &thread, 0, timestretch_thread, current_timestretch)) {
-               // GTK2FIX
-         //current_timestretch->close ();
+               current_timestretch->hide ();
                error << _("timestretch cannot be started - thread creation error") << endmsg;
                return -1;
        }
@@ -165,44 +156,46 @@ Editor::run_timestretch (AudioRegionSelection& regions, float fraction)
 
        c.disconnect ();
        
-       // GTK2FIX
-       // current_timestretch->close ();
+       current_timestretch->hide ();
        return current_timestretch->status;
 }
 
 void
 Editor::do_timestretch (TimeStretchDialog& dialog)
 {
-       AudioTrack* at;
-       Playlist* playlist;
-       AudioRegion* new_region;
+       Track*    t;
+       boost::shared_ptr<Playlist> playlist;
+       boost::shared_ptr<Region>   new_region;
 
-       for (AudioRegionSelection::iterator i = dialog.regions.begin(); i != dialog.regions.end(); ) {
+       for (RegionSelection::iterator i = dialog.regions.begin(); i != dialog.regions.end(); ) {
+               AudioRegionView* arv = dynamic_cast<AudioRegionView*>(*i);
+               if (!arv)
+                       continue;
 
-               AudioRegion& aregion ((*i)->region);
-               TimeAxisView* tv = &(*i)->get_time_axis_view();
-               AudioTimeAxisView* atv;
-               AudioRegionSelection::iterator tmp;
+               boost::shared_ptr<AudioRegion> region (arv->audio_region());
+               TimeAxisView* tv = &(arv->get_time_axis_view());
+               RouteTimeAxisView* rtv;
+               RegionSelection::iterator tmp;
                
                tmp = i;
                ++tmp;
 
-               if ((atv = dynamic_cast<AudioTimeAxisView*> (tv)) == 0) {
+               if ((rtv = dynamic_cast<RouteTimeAxisView*> (tv)) == 0) {
                        i = tmp;
                        continue;
                }
 
-               if ((at = dynamic_cast<AudioTrack*> (&atv->route())) == 0) {
+               if ((t = dynamic_cast<Track*> (rtv->route().get())) == 0) {
                        i = tmp;
                        continue;
                }
        
-               if ((playlist = at->disk_stream().playlist()) == 0) {
+               if ((playlist = t->diskstream()->playlist()) == 0) {
                        i = tmp;
                        continue;
                }
 
-               dialog.request.region = &aregion;
+               dialog.request.region = region;
 
                if (!dialog.request.running) {
                        /* we were cancelled */
@@ -216,15 +209,17 @@ Editor::do_timestretch (TimeStretchDialog& dialog)
                        return;
                }
 
-               session->add_undo (playlist->get_memento());
-               playlist->replace_region (aregion, *new_region, aregion.position());
-               session->add_redo_no_execute (playlist->get_memento());
+               XMLNode &before = playlist->get_state();
+               playlist->replace_region (region, new_region, region->position());
+               XMLNode &after = playlist->get_state();
+               session->add_command (new MementoCommand<Playlist>(*playlist, &before, &after));
 
                i = tmp;
        }
 
        dialog.status = 0;
        dialog.request.running = false;
+       dialog.request.region.reset ();
 }
 
 void*