All useage of ArdourPrompter checks for a valid result.
[ardour.git] / gtk2_ardour / audio_time_axis.cc
index 9b444966aa3f640fdfaf78dc3ba9c87932bcee2d..013635f9549c22408366fd09e0de3d8d78e9da94 100644 (file)
 
 #include <pbd/error.h>
 #include <pbd/stl_delete.h>
+#include <pbd/whitespace.h>
 
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/selector.h>
+#include <gtkmm2ext/bindable_button.h>
 #include <gtkmm2ext/gtk_ui.h>
+#include <gtkmm2ext/selector.h>
 #include <gtkmm2ext/stop_signal.h>
-#include <gtkmm2ext/bindable_button.h>
+#include <gtkmm2ext/utils.h>
 
-#include <ardour/session.h>
-#include <ardour/session_playlist.h>
 #include <ardour/audioplaylist.h>
 #include <ardour/diskstream.h>
-#include <ardour/utils.h>
-#include <ardour/playlist.h>
-#include <ardour/ladspa_plugin.h>
 #include <ardour/insert.h>
+#include <ardour/ladspa_plugin.h>
 #include <ardour/location.h>
 #include <ardour/panner.h>
+#include <ardour/playlist.h>
+#include <ardour/session.h>
+#include <ardour/session_playlist.h>
+#include <ardour/utils.h>
 
 #include "ardour_ui.h"
-#include "public_editor.h"
 #include "audio_time_axis.h"
-#include "streamview.h"
-#include "simplerect.h"
-#include "playlist_selector.h"
-#include "plugin_selector.h"
-#include "plugin_ui.h"
-#include "regionview.h"
 #include "automation_gain_line.h"
 #include "automation_pan_line.h"
 #include "automation_time_axis.h"
-#include "redirect_automation_time_axis.h"
+#include "canvas_impl.h"
+#include "crossfade_view.h"
+#include "enums.h"
 #include "gain_automation_time_axis.h"
+#include "gui_thread.h"
+#include "keyboard.h"
 #include "pan_automation_time_axis.h"
+#include "playlist_selector.h"
+#include "plugin_selector.h"
+#include "plugin_ui.h"
+#include "point_selection.h"
+#include "prompter.h"
+#include "public_editor.h"
 #include "redirect_automation_line.h"
+#include "redirect_automation_time_axis.h"
+#include "regionview.h"
+#include "rgb_macros.h"
 #include "selection.h"
-#include "point_selection.h"
-#include "enums.h"
+#include "simplerect.h"
+#include "streamview.h"
 #include "utils.h"
-#include "keyboard.h"
-#include "rgb_macros.h"
-#include "prompter.h"
-#include "crossfade_view.h"
-#include "gui_thread.h"
-#include "canvas_impl.h"
 
 #include <ardour/audio_track.h>
 
@@ -161,19 +162,13 @@ AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, Route& rt
        mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press));
        mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release));
        rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press));
-       edit_group_button.signal_button_release_event().connect (mem_fun(*this, &AudioTimeAxisView::edit_click));
+       edit_group_button.signal_button_release_event().connect (mem_fun(*this, &AudioTimeAxisView::edit_click), false);
        playlist_button.signal_clicked().connect (mem_fun(*this, &AudioTimeAxisView::playlist_click));
        automation_button.signal_clicked().connect (mem_fun(*this, &AudioTimeAxisView::automation_click));
-       size_button.signal_button_release_event().connect (mem_fun(*this, &AudioTimeAxisView::size_click));
+       size_button.signal_button_release_event().connect (mem_fun(*this, &AudioTimeAxisView::size_click), false);
        visual_button.signal_clicked().connect (mem_fun(*this, &AudioTimeAxisView::visual_click));
        hide_button.signal_clicked().connect (mem_fun(*this, &AudioTimeAxisView::hide_click));
 
-       name_entry.signal_activate().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_activated));
-       name_entry.signal_focus_out_event().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_focus_out_handler));
-       name_entry.signal_button_press_event().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_button_press_handler));
-       name_entry.signal_button_release_event().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_button_release_handler));
-       name_entry.signal_key_release_event().connect (mem_fun(*this, &AudioTimeAxisView::name_entry_key_release_handler));
-       
        if (is_audio_track()) {
                controls_table.attach (*rec_enable_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
        }
@@ -501,12 +496,10 @@ AudioTimeAxisView::show_timestretch (jack_nframes_t start, jack_nframes_t end)
        x2 = (end - 1) / editor.get_current_zoom();
        y2 = height - 2;
        
-       gtk_object_set (GTK_OBJECT(timestretch_rect), 
-                       "x1", x1,
-                       "y1", 1.0,
-                       "x2", x2,
-                       "y2", y2,
-                       NULL);
+       timestretch_rect->property_x1() = x1;
+       timestretch_rect->property_y1() = 1.0;
+       timestretch_rect->property_x2() = x2;
+       timestretch_rect->property_y2() = y2;
 }
 
 void
@@ -842,9 +835,11 @@ AudioTimeAxisView::rename_current_playlist ()
        prompter.set_initial_text (pl->name());
 
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (name);
-               pl->set_name (name);
+               if (name.length()) {
+                       pl->set_name (name);
+               }
                break;
 
        default:
@@ -881,11 +876,13 @@ AudioTimeAxisView::use_copy_playlist ()
        prompter.show_all ();
 
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (name);
-               ds->use_copy_playlist ();
-               pl = ds->playlist();
-               pl->set_name (name);
+               if (name.length()) {
+                       ds->use_copy_playlist ();
+                       pl = ds->playlist();
+                       pl->set_name (name);
+               }
                break;
 
        default:
@@ -911,11 +908,13 @@ AudioTimeAxisView::use_new_playlist ()
        prompter.set_initial_text (new_name);
        
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (name);
-               ds->use_new_playlist ();
-               pl = ds->playlist();
-               pl->set_name (name);
+               if (name.length()) {
+                       ds->use_new_playlist ();
+                       pl = ds->playlist();
+                       pl->set_name (name);
+               }
                break;
 
        default:
@@ -1038,7 +1037,7 @@ AudioTimeAxisView::get_selectables (jack_nframes_t start, jack_nframes_t end, do
        }
        
        jack_nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
-       jack_nframes_t end_adjusted = session_frame_to_track_frame(start, speed);
+       jack_nframes_t end_adjusted   = session_frame_to_track_frame(end, speed);
 
        if (view && touched (top, bot)) {
                view->get_selectables (start_adjusted, end_adjusted, results);
@@ -1093,59 +1092,11 @@ AudioTimeAxisView::playlist () const
        }
 }
 
-gint 
-AudioTimeAxisView::name_entry_button_press_handler (GdkEventButton *ev)
-{
-       if (ev->button == 3) {
-               return stop_signal (name_entry, "button_press_event");
-       }
-       return FALSE;
-}
-
-gint 
-AudioTimeAxisView::name_entry_button_release_handler (GdkEventButton *ev)
-{
-       return FALSE;
-}
-
-gint
-AudioTimeAxisView::name_entry_focus_out_handler (GdkEventFocus* ev)
-{
-       name_entry_changed ();
-       return TRUE;
-}
-
-gint
-AudioTimeAxisView::name_entry_key_release_handler (GdkEventKey* ev)
-{
-       switch (ev->keyval) {
-       case GDK_Tab:
-       case GDK_Up:
-       case GDK_Down:
-               name_entry_changed ();
-               return TRUE;
-
-       default:
-               return FALSE;
-       }
-}
-
-void
-AudioTimeAxisView::name_entry_activated ()
-{
-       /* this should drop focus from the entry,
-          and cause a call to name_entry_changed()
-       */
-       controls_ebox.grab_focus();
-}
-
 void
 AudioTimeAxisView::name_entry_changed ()
 {
        string x;
 
-       ARDOUR_UI::generic_focus_out_event (0);
-
        x = name_entry.get_text ();
        
        if (x == _route.name()) {
@@ -1176,7 +1127,7 @@ AudioTimeAxisView::visual_click ()
 void
 AudioTimeAxisView::hide_click ()
 {
-       editor.unselect_strip_in_display (*this);
+       editor.hide_track_in_display (*this);
 }
 
 Region*
@@ -1993,7 +1944,7 @@ AudioTimeAxisView::route_active_changed ()
 }
 
 XMLNode* 
-AudioTimeAxisView::get_child_xml_node (std::string childname)
+AudioTimeAxisView::get_child_xml_node (const string & childname)
 {
        return RouteUI::get_child_xml_node (childname);
 }