size-based scrolling and right-click pages for editor notebook
[ardour.git] / gtk2_ardour / editor_ops.cc
index 2f8d3a8cfd6fbf8e0ce7e6a9e3c136c6044c1873..77d9506a82976f6628906cd44cdaa233fbc0d326 100644 (file)
@@ -184,11 +184,11 @@ Do you really want to destroy %1 ?"),
 
        Gtkmm2ext::Choice prompter (prompt, choices);
 
-       prompter.chosen.connect (Gtk::Main::quit.slot());
+       prompter.chosen.connect (ptr_fun (Main::quit));
        prompter.show_all ();
 
-       Gtk::Main::run ();
-
+       Main::run ();
+               
        if (prompter.get_choice() != 0) {
                return;
        }
@@ -973,8 +973,7 @@ Editor::scroll_tracks_down ()
                cnt = (int) floor (prefix);
        }
 
-       Gtk::Adjustment *adj = track_canvas_scroller.get_vadjustment();
-       adj->set_value (adj->get_value() + (cnt * adj->get_page_size()));
+       vertical_adjustment.set_value (vertical_adjustment.get_value() + (cnt * vertical_adjustment.get_page_size()));
 }
 
 void
@@ -990,8 +989,7 @@ Editor::scroll_tracks_up ()
                cnt = (int) floor (prefix);
        }
 
-       Gtk::Adjustment *adj = track_canvas_scroller.get_vadjustment();
-       adj->set_value (adj->get_value() - (cnt * adj->get_page_size()));
+       vertical_adjustment.set_value (vertical_adjustment.get_value() - (cnt * vertical_adjustment.get_page_size()));
 }
 
 void
@@ -1120,7 +1118,7 @@ Editor::temporal_zoom_session ()
 }
 
 void
-Editor::temporal_zoom_by_frame (jack_nframes_t start, jack_nframes_t end, string op)
+Editor::temporal_zoom_by_frame (jack_nframes_t start, jack_nframes_t end, stringcr_t op)
 {
        if (!session) return;
 
@@ -1462,7 +1460,7 @@ Editor::clear_locations ()
 void
 Editor::insert_region_list_drag (AudioRegion& region)
 {
-       double x, y;
+       int x, y;
        double wx, wy;
        double cx, cy;
        TimeAxisView *tv;
@@ -1471,7 +1469,6 @@ Editor::insert_region_list_drag (AudioRegion& region)
        Playlist *playlist;
        
        track_canvas.get_pointer (x, y);
-
        track_canvas.window_to_world (x, y, wx, wy);
 
        GdkEvent event;
@@ -1529,7 +1526,7 @@ Editor::insert_region_list_selection (float times)
        
        Glib::RefPtr<TreeSelection> selected = region_list_display.get_selection();
        
-       if (selected.count_selected_rows() != 1) {
+       if (selected->count_selected_rows() != 1) {
                return;
        }
        
@@ -1819,23 +1816,21 @@ Editor::audition_playlist_region_standalone (AudioRegion& region)
 void
 Editor::build_interthread_progress_window ()
 {
-       interthread_progress_window = new ArdourDialog (X_("interthread progress"));
+       interthread_progress_window = new ArdourDialog (X_("interthread progress"), true);
 
        interthread_progress_bar.set_orientation (Gtk::PROGRESS_LEFT_TO_RIGHT);
        
-       interthread_progress_vbox.set_border_width (10);
-       interthread_progress_vbox.set_spacing (5);
-       interthread_progress_vbox.pack_start (interthread_progress_label, false, false);
-       interthread_progress_vbox.pack_start (interthread_progress_bar,false, false);
-       interthread_progress_vbox.pack_start (interthread_cancel_button,false, false);
+       interthread_progress_window->get_vbox()->pack_start (interthread_progress_label, false, false);
+       interthread_progress_window->get_vbox()->pack_start (interthread_progress_bar,false, false);
+
+       // GTK2FIX: this button needs a modifiable label
+
+       Button* b = interthread_progress_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
+       b->signal_clicked().connect (mem_fun(*this, &Editor::interthread_cancel_clicked));
 
        interthread_cancel_button.add (interthread_cancel_label);
 
-       interthread_cancel_button.signal_clicked().connect (mem_fun(*this, &Editor::interthread_cancel_clicked));
-       
-       interthread_progress_window->set_modal (true);
        interthread_progress_window->set_default_size (200, 100);
-       interthread_progress_window->add (interthread_progress_vbox);
 }
 
 void
@@ -1975,7 +1970,7 @@ Editor::do_import (vector<string> paths, bool split, bool as_tracks)
 }
 
 int
-Editor::reject_because_rate_differs (string path, SF_INFO& finfo, string action, bool multiple_pending)
+Editor::reject_because_rate_differs (stringcr_t path, SF_INFO& finfo, stringcr_t action, bool multiple_pending)
 {
        if (!session) {
                return 1;
@@ -2001,7 +1996,7 @@ Editor::reject_because_rate_differs (string path, SF_INFO& finfo, string action,
                        string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path),
                        choices);
 
-               rate_choice.chosen.connect (Main::quit.slot());
+               rate_choice.chosen.connect (ptr_fun (Main::quit));
                rate_choice.show_all ();
 
                Main::run ();
@@ -2104,7 +2099,7 @@ Editor::embed_sndfile (string path, bool split, bool multiple_files, bool& check
                }
        }
 
-       track_canvas_scroller.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
+       track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
        ARDOUR_UI::instance()->flush_pending ();
 
        /* make the proper number of channels in the region */
@@ -2152,7 +2147,7 @@ Editor::embed_sndfile (string path, bool split, bool multiple_files, bool& check
        }
 
   out:
-       track_canvas_scroller.get_window()->set_cursor (*current_canvas_cursor);
+       track_canvas.get_window()->set_cursor (*current_canvas_cursor);
 }
 
 void
@@ -2265,7 +2260,7 @@ Editor::do_insert_sndfile (vector<string> paths, bool split, jack_nframes_t pos)
 }
 
 void
-Editor::insert_sndfile_into (string path, bool multi, AudioTimeAxisView* tv, jack_nframes_t& pos, bool prompt)
+Editor::insert_sndfile_into (stringcr_t path, bool multi, AudioTimeAxisView* tv, jack_nframes_t& pos, bool prompt)
 {
        SndFileSource *source = 0; /* keep g++ quiet */
        AudioRegion::SourceList sources;
@@ -2290,7 +2285,7 @@ Editor::insert_sndfile_into (string path, bool multi, AudioTimeAxisView* tv, jac
                return;
        }
 
-       track_canvas_scroller.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
+       track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
        ARDOUR_UI::instance()->flush_pending ();
 
        /* make the proper number of channels in the region */
@@ -2333,7 +2328,7 @@ Editor::insert_sndfile_into (string path, bool multi, AudioTimeAxisView* tv, jac
        }
 
   out:
-       track_canvas_scroller.get_window()->set_cursor (*current_canvas_cursor);
+       track_canvas.get_window()->set_cursor (*current_canvas_cursor);
        return;
 }
 
@@ -2602,7 +2597,7 @@ Editor::region_fill_selection ()
 
        Glib::RefPtr<TreeSelection> selected = region_list_display.get_selection();
 
-       if (selected.count_selected_rows() != 1) {
+       if (selected->count_selected_rows() != 1) {
                return;
        }
 
@@ -2921,7 +2916,7 @@ Editor::freeze_route ()
 
        pthread_create (&itt.thread, 0, _freeze_thread, this);
 
-       track_canvas_scroller.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
+       track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
 
        while (!itt.done && !itt.cancel) {
                gtk_main_iteration ();
@@ -2930,7 +2925,7 @@ Editor::freeze_route ()
        interthread_progress_connection.disconnect ();
        interthread_progress_window->hide_all ();
        current_interthread_info = 0;
-       track_canvas_scroller.get_window()->set_cursor (*current_canvas_cursor);
+       track_canvas.get_window()->set_cursor (*current_canvas_cursor);
 }
 
 void
@@ -3167,7 +3162,7 @@ Editor::paste (float times)
 void
 Editor::mouse_paste ()
 {
-       double x, y;
+       int x, y;
        double wx, wy;
        track_canvas.get_pointer (x, y);
        track_canvas.window_to_world (x, y, wx, wy);
@@ -3216,11 +3211,11 @@ Editor::paste_internal (jack_nframes_t position, float times)
 void
 Editor::paste_named_selection (float times)
 {
-       TrackSelection::iterator i;
+       TrackSelection::iterator t;
 
        Glib::RefPtr<TreeSelection> selected = named_selection_display.get_selection();
 
-       if (selected.count_selected_rows() == 0 || selection->tracks.empty()) {
+       if (selected->count_selected_rows() != 1 || selection->tracks.empty()) {
                return;
        }
 
@@ -3234,13 +3229,13 @@ Editor::paste_named_selection (float times)
                
        begin_reversible_command (_("paste chunk"));
 
-       for (i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
+       for (t = selection->tracks.begin(); t != selection->tracks.end(); ++t) {
                
                AudioTimeAxisView* atv;
                Playlist* pl;
                AudioPlaylist* apl;
 
-               if ((atv = dynamic_cast<AudioTimeAxisView*> (*i)) == 0) {
+               if ((atv = dynamic_cast<AudioTimeAxisView*> (*t)) == 0) {
                        continue;
                }
 
@@ -3432,16 +3427,17 @@ Editor::remove_last_capture ()
 
                choices.push_back (_("Yes, destroy it."));
                choices.push_back (_("No, do nothing."));
-
+               
                Gtkmm2ext::Choice prompter (prompt, choices);
-               prompter.done.connect (Gtk::Main::quit.slot());
+               prompter.chosen.connect (ptr_fun (Main::quit));
                prompter.show_all ();
 
-               Gtk::Main::run ();
-
+               Main::run ();
+               
                if (prompter.get_choice() == 0) {
                        session->remove_last_capture ();
                }
+
        } else {
                session->remove_last_capture();
        }
@@ -3460,7 +3456,7 @@ Editor::normalize_region ()
 
        begin_reversible_command (_("normalize"));
 
-       track_canvas_scroller.get_window()->set_cursor (*wait_cursor);
+       track_canvas.get_window()->set_cursor (*wait_cursor);
        gdk_flush ();
 
        for (AudioRegionSelection::iterator r = selection->audio_regions.begin(); r != selection->audio_regions.end(); ++r) {
@@ -3470,7 +3466,7 @@ Editor::normalize_region ()
        }
 
        commit_reversible_command ();
-       track_canvas_scroller.get_window()->set_cursor (*current_canvas_cursor);
+       track_canvas.get_window()->set_cursor (*current_canvas_cursor);
 }
 
 
@@ -3517,7 +3513,7 @@ Editor::apply_filter (AudioFilter& filter, string command)
 
        begin_reversible_command (command);
 
-       track_canvas_scroller.get_window()->set_cursor (*wait_cursor);
+       track_canvas.get_window()->set_cursor (*wait_cursor);
        gdk_flush ();
 
        for (AudioRegionSelection::iterator r = selection->audio_regions.begin(); r != selection->audio_regions.end(); ) {
@@ -3546,7 +3542,7 @@ Editor::apply_filter (AudioFilter& filter, string command)
        selection->audio_regions.clear ();
 
   out:
-       track_canvas_scroller.get_window()->set_cursor (*current_canvas_cursor);
+       track_canvas.get_window()->set_cursor (*current_canvas_cursor);
 }
 
 void