enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / gtk2_ardour / editor_canvas.cc
index 36c9e341027a02c6b241db823afe49629b74ed04..4fbe0d844404746c3d6b531578f8b1b4a36668a4 100644 (file)
@@ -54,7 +54,7 @@
 #include "ui_config.h"
 #include "verbose_cursor.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -98,18 +98,6 @@ Editor::initialize_canvas ()
 
        _verbose_cursor = new VerboseCursor (this);
 
-       /* on the bottom, an image */
-
-       if (Profile->get_sae()) {
-               Image img (::get_icon (X_("saelogo")));
-               // logo_item = new ArdourCanvas::Pixbuf (_track_canvas->root(), 0.0, 0.0, img.get_pixbuf());
-               // logo_item->property_height_in_pixels() = true;
-               // logo_item->property_width_in_pixels() = true;
-               // logo_item->property_height_set() = true;
-               // logo_item->property_width_set() = true;
-               // logo_item->show ();
-       }
-
        /*a group to hold global rects like punch/loop indicators */
        global_rect_group = new ArdourCanvas::Container (hv_scroll_group);
        CANVAS_DEBUG_NAME (global_rect_group, "global rect group");
@@ -227,10 +215,6 @@ Editor::initialize_canvas ()
 
        playhead_cursor = new EditorCursor (*this, &Editor::canvas_playhead_cursor_event);
 
-       if (logo_item) {
-               logo_item->lower_to_bottom ();
-       }
-
        _canvas_drop_zone = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, 0.0));
        /* this thing is transparent */
        _canvas_drop_zone->set_fill (false);
@@ -329,7 +313,7 @@ Editor::reset_controls_layout_width ()
        edit_controls_vbox.size_request (req);
        w = req.width;
 
-        if (_group_tabs->is_mapped()) {
+        if (_group_tabs->is_visible()) {
                _group_tabs->size_request (req);
                 w += req.width;
         }
@@ -428,7 +412,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, framepos_t frame, doub
                InstrumentSelector is; // instantiation builds instrument-list and sets default.
                do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, frame, is.selected_instrument());
 
-               if (Profile->get_sae() || UIConfiguration::instance().get_only_copy_imported_files() || copy) {
+               if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
                        do_import (audio_paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, SrcBest, frame);
                } else {
                        do_embed (audio_paths, Editing::ImportDistinctFiles, ImportAsTrack, frame);
@@ -444,7 +428,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, framepos_t frame, doub
 
                        do_import (midi_paths, Editing::ImportSerializeFiles, ImportToTrack, SrcBest, frame);
 
-                       if (Profile->get_sae() || UIConfiguration::instance().get_only_copy_imported_files() || copy) {
+                       if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
                                do_import (audio_paths, Editing::ImportSerializeFiles, Editing::ImportToTrack, SrcBest, frame);
                        } else {
                                do_embed (audio_paths, Editing::ImportSerializeFiles, ImportToTrack, frame);
@@ -478,7 +462,7 @@ 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
+#ifdef __APPLE__
                /* 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.
@@ -500,6 +484,12 @@ Editor::drop_paths (const RefPtr<Gdk::DragContext>& context,
 void
 Editor::maybe_autoscroll (bool allow_horiz, bool allow_vert, bool from_headers)
 {
+       Gtk::Window* toplevel = dynamic_cast<Gtk::Window*>(contents().get_toplevel());
+
+       if (!toplevel) {
+               return;
+       }
+
        if (!UIConfiguration::instance().get_autoscroll_editor () || autoscroll_active ()) {
                return;
        }
@@ -557,7 +547,7 @@ Editor::maybe_autoscroll (bool allow_horiz, bool allow_vert, bool from_headers)
        int x, y;
        Gdk::ModifierType mask;
 
-       get_window()->get_pointer (x, y, mask);
+       toplevel->get_window()->get_pointer (x, y, mask);
 
        if ((allow_horiz && ((x < scrolling_boundary.x0 && leftmost_frame > 0) || x >= scrolling_boundary.x1)) ||
            (allow_vert && ((y < scrolling_boundary.y0 && vertical_adjustment.get_value() > 0)|| y >= scrolling_boundary.y1))) {
@@ -578,8 +568,13 @@ Editor::autoscroll_canvas ()
        Gdk::ModifierType mask;
        frameoffset_t dx = 0;
        bool no_stop = false;
+       Gtk::Window* toplevel = dynamic_cast<Gtk::Window*>(contents().get_toplevel());
+
+       if (!toplevel) {
+               return false;
+       }
 
-       get_window()->get_pointer (x, y, mask);
+       toplevel->get_window()->get_pointer (x, y, mask);
 
        VisualChange vc;
        bool vertical_motion = false;
@@ -643,6 +638,7 @@ Editor::autoscroll_canvas ()
                                scroll_up_one_track ();
                                vertical_motion = true;
                        }
+                       no_stop = true;
 
                } else if (y > autoscroll_boundary.y1) {
 
@@ -650,9 +646,9 @@ Editor::autoscroll_canvas ()
                                scroll_down_one_track ();
                                vertical_motion = true;
                        }
+                       no_stop = true;
                }
 
-               no_stop = true;
        }
 
        if (vc.pending || vertical_motion) {
@@ -682,7 +678,7 @@ Editor::autoscroll_canvas ()
                int cx;
                int cy;
 
-               translate_coordinates (*_track_canvas, x, y, cx, cy);
+               toplevel->translate_coordinates (*_track_canvas, x, y, cx, cy);
 
                /* clamp x and y to remain within the autoscroll boundary,
                 * which is defined in window coordinates
@@ -698,6 +694,7 @@ Editor::autoscroll_canvas ()
                ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (cx, cy));
                ev.x = d.x;
                ev.y = d.y;
+               ev.state = mask;
 
                motion_handler (0, (GdkEvent*) &ev, true);
 
@@ -733,11 +730,12 @@ Editor::autoscroll_canvas ()
                }
                y = min (max ((ArdourCanvas::Coord) y, autoscroll_boundary.y0), autoscroll_boundary.y1);
 
-               translate_coordinates (*_track_canvas_viewport, x, y, cx, cy);
+               toplevel->translate_coordinates (*_track_canvas_viewport, x, y, cx, cy);
 
                ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (cx, cy));
                ev.x = d.x;
                ev.y = d.y;
+               ev.state = mask;
 
                motion_handler (0, (GdkEvent*) &ev, true);
 
@@ -760,7 +758,6 @@ Editor::start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const Ardour
 
        stop_canvas_autoscroll ();
 
-       autoscroll_cnt = 0;
        autoscroll_horizontal_allowed = allow_horiz;
        autoscroll_vertical_allowed = allow_vert;
        autoscroll_boundary = boundary;
@@ -779,6 +776,7 @@ void
 Editor::stop_canvas_autoscroll ()
 {
        autoscroll_connection.disconnect ();
+       autoscroll_cnt = 0;
 }
 
 Editor::EnterContext*