diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-04-21 02:24:38 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-04-21 02:24:38 +0000 |
commit | d9cebc2edf8accded23c6f2a1caab73eb47a50fd (patch) | |
tree | 976c94ef8ec19b8e5149675eb5092ab6e9cb20de /gtk2_ardour | |
parent | cf77196698a395e4174037f36f755b401de679f3 (diff) |
commits 6001-6525 inclusive from 2.X applied to 3.0
git-svn-id: svn://localhost/ardour2/branches/3.0@6942 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/ardour.menus.in | 1 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 89 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 9 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui2.cc | 30 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_ed.cc | 8 | ||||
-rw-r--r-- | gtk2_ardour/editor.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/gettext.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/plugin_selector.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/processor_box.cc | 26 | ||||
-rw-r--r-- | gtk2_ardour/utils.cc | 113 |
10 files changed, 212 insertions, 72 deletions
diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index f52152416e..f7234ed8c0 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -8,6 +8,7 @@ <menuitem action='Close'/> <separator/> <menuitem action='Save'/> + <menuitem action='SaveAs'/> <menuitem action='Snapshot'/> <menuitem action='SaveTemplate'/> <menu name='Metadata' action='Metadata'> diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index c24d16bcd1..0944686f4e 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -343,9 +343,10 @@ ARDOUR_UI::create_engine () engine->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context()); engine->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this), gui_context()); - engine->Halted.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_halted, this), gui_context()); engine->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, ui_bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context()); + engine->Halted.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false)); + post_engine (); return 0; @@ -726,10 +727,11 @@ void ARDOUR_UI::finish() { if (_session) { + int tries = 0; - if (_session->transport_rolling()) { - _session->request_stop (); - usleep (250000); + if (_session->transport_rolling() && (++tries < 8)) { + _session->request_stop (false, true); + usleep (10000); } if (_session->dirty()) { @@ -1444,14 +1446,14 @@ ARDOUR_UI::transport_stop () return; } - _session->request_stop (); + _session->request_stop (false, true); } void ARDOUR_UI::transport_stop_and_forget_capture () { if (_session) { - _session->request_stop (true); + _session->request_stop (true, true); } } @@ -1519,7 +1521,12 @@ ARDOUR_UI::transport_roll () bool rolling = _session->transport_rolling(); if (_session->get_play_loop()) { - _session->request_play_loop (false, true); + /* XXX it is not possible to just leave seamless loop and keep + playing at present (nov 4th 2009) + */ + if (!Config->get_seamless_loop()) { + _session->request_play_loop (false, true); + } } else if (_session->get_play_range () && !join_play_range_button.get_active()) { /* stop playing a range if we currently are */ _session->request_play_range (0, true); @@ -1576,7 +1583,7 @@ ARDOUR_UI::toggle_roll (bool with_abort, bool roll_out_of_bounded_mode) _session->request_play_loop (false, true); } else if (_session->get_play_range ()) { affect_transport = false; - _session->request_play_range (0, true); + _session->request_play_range (0, true); } } @@ -1826,23 +1833,46 @@ ARDOUR_UI::engine_running () } void -ARDOUR_UI::engine_halted () +ARDOUR_UI::engine_halted (const char* reason, bool free_reason) { - ENSURE_GUI_THREAD (*this, &ARDOUR_UI::engine_halted) + if (!Gtkmm2ext::UI::instance()->caller_is_ui_thread()) { + /* we can't rely on the original string continuing to exist when we are called + again in the GUI thread, so make a copy and note that we need to + free it later. + */ + char *copy = strdup (reason); + Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&ARDOUR_UI::engine_halted, this, copy, true)); + return; + } ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, false); ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, true); update_sample_rate (0); - MessageDialog msg (*editor, - _("\ + string msgstr; + + /* if the reason is a non-empty string, it means that the backend was shutdown + rather than just Ardour. + */ + + if (strlen (reason)) { + msgstr = string_compose (_("The audio backend (JACK) was shutdown because:\n\n%1"), reason); + } else { + msgstr = _("\ JACK has either been shutdown or it\n\ disconnected Ardour because Ardour\n\ was not fast enough. Try to restart\n\ -JACK, reconnect and save the session.")); +JACK, reconnect and save the session."); + } + + MessageDialog msg (*editor, msgstr); pop_back_splash (); msg.run (); + + if (free_reason) { + free ((char*) reason); + } } int32_t @@ -1940,24 +1970,29 @@ ARDOUR_UI::stop_blinking () /** Ask the user for the name of a new shapshot and then take it. */ + void -ARDOUR_UI::snapshot_session () +ARDOUR_UI::snapshot_session (bool switch_to_it) { ArdourPrompter prompter (true); string snapname; - char timebuf[128]; - time_t n; - struct tm local_time; - - time (&n); - localtime_r (&n, &local_time); - strftime (timebuf, sizeof(timebuf), "%FT%T", &local_time); prompter.set_name ("Prompter"); prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); prompter.set_title (_("Take Snapshot")); + prompter.set_title (_("Take Snapshot")); prompter.set_prompt (_("Name of New Snapshot")); - prompter.set_initial_text (timebuf); + + if (!switch_to_it) { + char timebuf[128]; + time_t n; + struct tm local_time; + + time (&n); + localtime_r (&n, &local_time); + strftime (timebuf, sizeof(timebuf), "%FT%T", &local_time); + prompter.set_initial_text (timebuf); + } again: switch (prompter.run()) { @@ -2000,7 +2035,7 @@ ARDOUR_UI::snapshot_session () } if (do_save) { - save_state (snapname); + save_state (snapname, switch_to_it); } break; } @@ -2011,13 +2046,13 @@ ARDOUR_UI::snapshot_session () } void -ARDOUR_UI::save_state (const string & name) +ARDOUR_UI::save_state (const string & name, bool switch_to_it) { - save_state_canfail (name); + save_state_canfail (name, switch_to_it); } int -ARDOUR_UI::save_state_canfail (string name) +ARDOUR_UI::save_state_canfail (string name, bool switch_to_it) { if (_session) { int ret; @@ -2026,7 +2061,7 @@ ARDOUR_UI::save_state_canfail (string name) name = _session->snap_name(); } - if ((ret = _session->save_state (name)) != 0) { + if ((ret = _session->save_state (name, false, switch_to_it)) != 0) { return ret; } } diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 6699b423cc..f8b8ec0407 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -147,8 +147,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr int unload_session (bool hide_stuff = false); void close_session(); - int save_state_canfail (std::string state_name = ""); - void save_state (const std::string & state_name = ""); + int save_state_canfail (std::string state_name = "", bool switch_to_it = false); + void save_state (const std::string & state_name = "", bool switch_to_it = false); static double gain_to_slider_position (ARDOUR::gain_t g); static ARDOUR::gain_t slider_position_to_gain (double pos); @@ -282,7 +282,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr void map_transport_state (); int32_t do_engine_start (); - void engine_halted (); + void engine_halted (const char* reason, bool free_reason); void engine_stopped (); void engine_running (); @@ -567,7 +567,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr guint32 last_key_press_time; - void snapshot_session (); + void snapshot_session (bool switch_to_it); Mixer_UI *mixer; int create_mixer (); @@ -694,6 +694,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag, const char *msg); Gtk::Label status_bar_label; + bool status_bar_button_press (GdkEventButton*); Gtk::ToggleButton error_log_button; void loading_message (const std::string& msg); diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 543ff7aeeb..8aa28e2685 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -76,12 +76,21 @@ ARDOUR_UI::setup_windows () #ifdef TOP_MENUBAR HBox* status_bar_packer = manage (new HBox); + EventBox* status_bar_event_box = manage (new EventBox); + status_bar_event_box->add (status_bar_label); + status_bar_event_box->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); status_bar_label.set_size_request (300, -1); - status_bar_packer->pack_start (status_bar_label, true, true, 6); + status_bar_packer->pack_start (*status_bar_event_box, true, true, 6); status_bar_packer->pack_start (error_log_button, false, false); - error_log_button.signal_clicked().connect (sigc::mem_fun (*this, &UI::toggle_errors)); + status_bar_label.show (); + status_bar_event_box->show (); + status_bar_packer->show (); + error_log_button.show (); + + error_log_button.signal_clicked().connect (mem_fun (*this, &UI::toggle_errors)); + status_bar_event_box->signal_button_press_event().connect (mem_fun (*this, &ARDOUR_UI::status_bar_button_press)); editor->get_status_bar_packer().pack_start (*status_bar_packer, true, true); editor->get_status_bar_packer().pack_start (menu_bar_base, false, false, 6); @@ -133,6 +142,23 @@ ARDOUR_UI::setup_tooltips () editor->setup_tooltips (); } +bool +ARDOUR_UI::status_bar_button_press (GdkEventButton* ev) +{ + bool handled = false; + + switch (ev->button) { + case 1: + status_bar_label.set_text (""); + handled = true; + break; + default: + break; + } + + return handled; +} + void ARDOUR_UI::display_message (const char *prefix, gint prefix_len, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg) { diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index f3bc96c6c5..49b6629c75 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -136,7 +136,11 @@ ARDOUR_UI::install_actions () #endif - act = ActionManager::register_action (main_actions, X_("Snapshot"), _("Snapshot..."), sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session)); + act = ActionManager::register_action (main_actions, X_("Snapshot"), _("Snapshot..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session), false)); + ActionManager::session_sensitive_actions.push_back (act); + ActionManager::write_sensitive_actions.push_back (act); + + act = ActionManager::register_action (main_actions, X_("SaveAs"), _("SaveAs ..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session), true)); ActionManager::session_sensitive_actions.push_back (act); ActionManager::write_sensitive_actions.push_back (act); @@ -237,7 +241,7 @@ ARDOUR_UI::install_actions () //act = ActionManager::register_action (common_actions, X_("AddMidiBus"), _("Add Midi Bus"), sigc::mem_fun(*this, &ARDOUR_UI::session_add_midi_bus)); //ActionManager::session_sensitive_actions.push_back (act); #endif - act = ActionManager::register_action (common_actions, X_("Save"), _("Save"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::save_state), string(""))); + act = ActionManager::register_action (common_actions, X_("Save"), _("Save"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::save_state), string(""), false)); ActionManager::session_sensitive_actions.push_back (act); ActionManager::write_sensitive_actions.push_back (act); act = ActionManager::register_action (common_actions, X_("RemoveLastCapture"), _("Remove Last Capture"), sigc::mem_fun(*this, &ARDOUR_UI::remove_last_capture)); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index d9ca85b939..bb8996ba93 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1493,7 +1493,7 @@ Editor::build_track_region_context_menu (nframes64_t frame) boost::shared_ptr<Region> dummy_region; // = NULL add_region_context_items (rtv->view(), dummy_region, edit_items); } else { - for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) { + for (Playlist::RegionList::reverse_iterator i = regions->rbegin(); i != regions->rend(); ++i) { add_region_context_items (rtv->view(), (*i), edit_items); } } @@ -1541,7 +1541,7 @@ Editor::build_track_crossfade_context_menu (nframes64_t frame) boost::shared_ptr<Region> dummy_region; // = NULL add_region_context_items (atv->audio_view(), dummy_region, edit_items); } else { - for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) { + for (Playlist::RegionList::reverse_iterator i = regions->rbegin(); i != regions->rend(); ++i) { add_region_context_items (atv->audio_view(), (*i), edit_items); } } diff --git a/gtk2_ardour/gettext.h b/gtk2_ardour/gettext.h index 339c74ffe7..2645402e95 100644 --- a/gtk2_ardour/gettext.h +++ b/gtk2_ardour/gettext.h @@ -20,7 +20,7 @@ #define _LIBGETTEXT_H 1 /* NLS can be disabled through the configure --disable-nls option. */ -#if ENABLE_NLS +#ifdef ENABLE_NLS /* Get declarations of GNU message catalog functions. */ # include <libintl.h> diff --git a/gtk2_ardour/plugin_selector.cc b/gtk2_ardour/plugin_selector.cc index 9c0ab70a26..890c09ede2 100644 --- a/gtk2_ardour/plugin_selector.cc +++ b/gtk2_ardour/plugin_selector.cc @@ -586,7 +586,7 @@ PluginSelector::build_plugin_menu () delete _plugin_menu; - _plugin_menu = new Menu; + _plugin_menu = manage (new Menu); _plugin_menu->set_name("ArdourContextMenu"); MenuList& items = _plugin_menu->items(); diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index add816e40f..42711b4936 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -1242,11 +1242,27 @@ ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor) case Gtk::RESPONSE_ACCEPT: name_prompter.get_result (result); if (result.length()) { - if (_session->route_by_name (result)) { - ARDOUR_UI::instance()->popup_error (_("A track already exists with that name.")); - return; - } - processor->set_name (result); + + int tries = 0; + string test = result; + + while (tries < 100) { + if (_session->io_name_is_legal (test)) { + result = test; + break; + } + tries++; + + test = string_compose ("%1-%2", result, tries); + } + + if (tries < 100) { + processor->set_name (result); + } else { + /* unlikely! */ + ARDOUR_UI::instance()->popup_error + (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result)); + } } break; } diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index aa57a3b773..e96137ee2c 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -504,12 +504,6 @@ set_color (Gdk::Color& c, int rgb) c.set_rgb((rgb >> 16)*256, ((rgb & 0xff00) >> 8)*256, (rgb & 0xff)*256); } -#ifdef GTKOSX -extern "C" { - gboolean gdk_quartz_possibly_forward (GdkEvent*); -} -#endif - bool relay_key_press (GdkEventKey* ev, Gtk::Window* win) { @@ -526,6 +520,73 @@ forward_key_press (GdkEventKey* ev) return PublicEditor::instance().on_key_press_event(ev); } +#ifdef GTKOSX +static guint +osx_keyval_without_alt (guint accent_keyval) +{ + switch (accent_keyval) { + case GDK_oe: + return GDK_q; + case GDK_registered: + return GDK_r; + case GDK_dagger: + return GDK_t; + case GDK_yen: + return GDK_y; + case GDK_diaeresis: + return GDK_u; + case GDK_oslash: + return GDK_o; + case GDK_Greek_pi: + return GDK_p; + case GDK_leftdoublequotemark: + return GDK_bracketleft; + case GDK_leftsinglequotemark: + return GDK_bracketright; + case GDK_guillemotleft: + return GDK_backslash; + case GDK_aring: + return GDK_a; + case GDK_ssharp: + return GDK_s; + case GDK_partialderivative: + return GDK_d; + case GDK_function: + return GDK_f; + case GDK_copyright: + return GDK_g; + case GDK_abovedot: + return GDK_h; + case GDK_notsign: + return GDK_l; + case GDK_ellipsis: + return GDK_semicolon; + case GDK_ae: + return GDK_apostrophe; + case GDK_Greek_OMEGA: + return GDK_z; + case GDK_ccedilla: + return GDK_c; + case GDK_radical: + return GDK_v; + case GDK_integral: + return GDK_b; + case GDK_mu: + return GDK_m; + case GDK_lessthanequal: + return GDK_comma; + case GDK_greaterthanequal: + return GDK_period; + case GDK_division: + return GDK_slash; + default: + break; + } + + return GDK_VoidSymbol; +} +#endif + bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) { @@ -595,6 +656,24 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) all "normal text" accelerators. */ +#ifdef GTKOSX + if (!special_handling_of_unmodified_accelerators) { + if (ev->state & GDK_MOD1_MASK) { + /* we're not in a text entry or "magic focus" widget so we don't want OS X "special-character" + text-style handling of alt-<key>. change the keyval back to what it would be without + the alt key. this way, we see <alt>-v rather than <alt>-radical and so on. + */ + guint keyval_without_alt = osx_keyval_without_alt (ev->keyval); + + if (keyval_without_alt != GDK_VoidSymbol) { +#ifdef DEBUG_ACCELERATOR_HANDLING + cerr << "Remapped " << gdk_keyval_name (ev->keyval) << " to " << gdk_keyval_name (keyval_without_alt) << endl; + +#endif ev->keyval = keyval_without_alt; + } + } + } +#endif if (!special_handling_of_unmodified_accelerators) { @@ -609,17 +688,6 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) if (allow_activating && gtk_accel_groups_activate(G_OBJECT(win), fakekey, GdkModifierType(ev->state))) { return true; } - -#ifdef GTKOSX - if (allow_activating) { - int oldval = ev->keyval; - ev->keyval = fakekey; - if (gdk_quartz_possibly_forward ((GdkEvent*) ev)) { - return true; - } - ev->keyval = oldval; - } -#endif } } @@ -638,11 +706,6 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) #endif if (allow_activating) { -#ifdef GTKOSX - if (gdk_quartz_possibly_forward ((GdkEvent*) ev)) { - return true; - } -#endif if (gtk_window_activate_key (win, ev)) { return true; } @@ -671,12 +734,6 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) #endif if (allow_activating) { - -#ifdef GTKOSX - if (gdk_quartz_possibly_forward ((GdkEvent*) ev)) { - return true; - } -#endif return gtk_window_activate_key (win, ev); } |