From 54d00408c3a1d36899fdd8b4f085aa2a2946009e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 17 Aug 2010 02:48:24 +0000 Subject: [PATCH] forward port 2.X changes up to and including rev 6842 git-svn-id: svn://localhost/ardour2/branches/3.0@7637 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 21 +++++++ gtk2_ardour/ardour_ui.h | 2 + gtk2_ardour/ardour_ui_ed.cc | 11 ++-- gtk2_ardour/crossfade_edit.cc | 5 +- gtk2_ardour/main.cc | 2 + libs/ardour/crossfade.cc | 6 ++ libs/gtkmm2ext/application.cc | 84 +++++++++++++++++++++++++ libs/gtkmm2ext/gtk_ui.cc | 26 ++------ libs/gtkmm2ext/gtkapplication_quartz.mm | 32 ++++++++-- libs/gtkmm2ext/gtkmm2ext/application.h | 63 +++++++++++++++++++ libs/gtkmm2ext/wscript | 1 + wscript | 2 +- 12 files changed, 219 insertions(+), 36 deletions(-) create mode 100644 libs/gtkmm2ext/application.cc create mode 100644 libs/gtkmm2ext/gtkmm2ext/application.h diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 388af95200..dd6da1e246 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -2656,6 +2656,15 @@ ARDOUR_UI::load_session (const Glib::ustring& path, const Glib::ustring& snap_na goto out; } + /* Now the session been created, add the transport controls */ + new_session->add_controllable(roll_controllable); + new_session->add_controllable(stop_controllable); + new_session->add_controllable(goto_start_controllable); + new_session->add_controllable(goto_end_controllable); + new_session->add_controllable(auto_loop_controllable); + new_session->add_controllable(play_selection_controllable); + new_session->add_controllable(rec_controllable); + set_session (new_session); session_loaded = true; @@ -2752,6 +2761,18 @@ ARDOUR_UI::show_about () about->show_all (); } +void +ARDOUR_UI::launch_manual () +{ + PBD::open_uri("http://ardour.org/flossmanual"); +} + +void +ARDOUR_UI::launch_reference () +{ + PBD::open_uri("http://ardour.org/refmanual"); +} + void ARDOUR_UI::hide_about () { diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 20660307cc..cccc4ab5b0 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -117,6 +117,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr void hide_splash (); void launch_chat (); + void launch_manual (); + void launch_reference (); void show_about (); void hide_about (); diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 4e02d48f9f..efdbd13add 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -48,9 +48,7 @@ #include "startup.h" #include "utils.h" -#ifdef GTKOSX -#include -#endif +#include #include "ardour/session.h" #include "ardour/profile.h" @@ -231,6 +229,8 @@ ARDOUR_UI::install_actions () ActionManager::session_sensitive_actions.push_back (act); ActionManager::register_action (common_actions, X_("About"), _("About"), sigc::mem_fun(*this, &ARDOUR_UI::show_about)); ActionManager::register_action (common_actions, X_("Chat"), _("Chat"), sigc::mem_fun(*this, &ARDOUR_UI::launch_chat)); + ActionManager::register_action (common_actions, X_("Manual"), _("Manual"), mem_fun(*this, &ARDOUR_UI::launch_manual)); + ActionManager::register_action (common_actions, X_("Reference"), _("Reference"), mem_fun(*this, &ARDOUR_UI::launch_reference)); ActionManager::register_toggle_action (common_actions, X_("ToggleThemeManager"), _("Theme Manager"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_theme_manager)); ActionManager::register_toggle_action (common_actions, X_("ToggleKeyEditor"), _("Key Bindings"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_key_editor)); ActionManager::register_toggle_action (common_actions, X_("ToggleBundleManager"), _("Bundle Manager"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_bundle_manager)); @@ -547,10 +547,7 @@ ARDOUR_UI::build_menu_bar () void ARDOUR_UI::use_menubar_as_top_menubar () { -#ifdef GTKOSX - ige_mac_menu_set_menu_bar ((GtkMenuShell*) menu_bar->gobj()); - // ige_mac_menu_set_quit_menu_item (some_item->gobj()); -#endif + gtk_application_set_menu_bar ((GtkMenuShell*) menu_bar->gobj()); } void diff --git a/gtk2_ardour/crossfade_edit.cc b/gtk2_ardour/crossfade_edit.cc index ecb7b8a1f8..b6dcf07920 100644 --- a/gtk2_ardour/crossfade_edit.cc +++ b/gtk2_ardour/crossfade_edit.cc @@ -419,15 +419,16 @@ CrossfadeEditor::point_event (GdkEvent* event, Point* point) if (point_grabbed) { double new_x, new_y; - /* can't drag first or last points horizontally */ + /* can't drag first or last points horizontally or vertically */ if (point == fade[current].points.front() || point == fade[current].points.back()) { new_x = point->x; + new_y = point->y; } else { new_x = (event->motion.x - canvas_border)/effective_width(); + new_y = 1.0 - ((event->motion.y - canvas_border)/effective_height()); } - new_y = 1.0 - ((event->motion.y - canvas_border)/effective_height()); point->move_to (x_coordinate (new_x), y_coordinate (new_y), new_x, new_y); redraw (); diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index a512af74a3..c17d39d2a2 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -39,6 +39,7 @@ #include "ardour/filesystem_paths.h" #include +#include #include #include @@ -439,6 +440,7 @@ int main (int argc, char *argv[]) } ui->run (text_receiver); + Gtkmm2ext::Application::instance()->cleanup(); ui = 0; ARDOUR::cleanup (); diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index 40857bd56a..aa203c3940 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -837,6 +837,9 @@ Crossfade::set_state (const XMLNode& node, int /*version*/) } } + _fade_in.front()->value = 0.0; + _fade_in.back()->value = 1.0; + _fade_in.thaw (); /* fade out */ @@ -862,6 +865,9 @@ Crossfade::set_state (const XMLNode& node, int /*version*/) } } + _fade_out.front()->value = 1.0; + _fade_out.back()->value = 0.0; + _fade_out.thaw (); PropertyChanged (what_changed); /* EMIT SIGNAL */ diff --git a/libs/gtkmm2ext/application.cc b/libs/gtkmm2ext/application.cc new file mode 100644 index 0000000000..54efb4773f --- /dev/null +++ b/libs/gtkmm2ext/application.cc @@ -0,0 +1,84 @@ +/* GTK+ Integration with platform-specific application-wide features + * such as the OS X menubar and application delegate concepts. + * + * Copyright (C) 2007 Pioneer Research Center USA, Inc. + * Copyright (C) 2007 Imendio AB + * Copyright (C) 2009 Paul Davis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "gtkmm2ext/application.h" +#include "gtkmm2ext/gtkapplication.h" + +using namespace Gtk; +using namespace Gtkmm2ext; + +Application* Application::_instance = 0; + +Application* +Application::instance () +{ + if (!_instance) { + _instance = new Application; + } + return _instance; +} + +Application::Application () +{ + gtk_application_init (); +} + +Application::~Application () +{ + _instance = 0; + gtk_application_cleanup (); +} + +void +Application::ready () +{ + gtk_application_ready (); +} + +void +Application::cleanup () +{ + gtk_application_cleanup (); +} + +void +Application::set_menu_bar (MenuShell& shell) +{ + gtk_application_set_menu_bar (shell.gobj()); +} + +GtkApplicationMenuGroup* +Application::add_app_menu_group () +{ + return gtk_application_add_app_menu_group (); +} + +void +Application::add_app_menu_item (GtkApplicationMenuGroup* group, + MenuItem* item) +{ + gtk_application_add_app_menu_item (group, item->gobj()); +} diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index 456b8e29c8..d1ef1e27c4 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -107,6 +108,10 @@ UI::UI (string namestr, int *argc, char ***argv) errors->set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY); //load_rcfile (rcfile); + + /* instantiate the Application singleton */ + + Application::instance(); } UI::~UI () @@ -633,31 +638,10 @@ UI::popup_error (const string& text) pup->touch (); } -#ifdef GTKOSX -extern "C" { - int gdk_quartz_in_carbon_menu_event_handler (); -} -#endif void UI::flush_pending () { -#ifdef GTKOSX - /* as of february 11th 2008, gtk/osx has a problem in that mac menu events - are handled using Carbon with an "internal" event handling system that - doesn't pass things back to the glib/gtk main loop. this makes - gtk_main_iteration() block if we call it while in a menu event handler - because glib gets confused and thinks there are two threads running - g_main_poll_func(). - - this hack (relies on code in gtk2_ardour/sync-menu.c) works - around that. - */ - - if (gdk_quartz_in_carbon_menu_event_handler()) { - return; - } -#endif if (!caller_is_ui_thread()) { error << "non-UI threads cannot call UI::flush_pending()" << endmsg; diff --git a/libs/gtkmm2ext/gtkapplication_quartz.mm b/libs/gtkmm2ext/gtkapplication_quartz.mm index b6d6b71d5d..c5fb8b12e2 100644 --- a/libs/gtkmm2ext/gtkapplication_quartz.mm +++ b/libs/gtkmm2ext/gtkapplication_quartz.mm @@ -50,6 +50,8 @@ * */ +static gint _exiting = 0; + static guint gdk_quartz_keyval_to_ns_keyval (guint keyval) { @@ -891,9 +893,13 @@ cocoa_menu_item_accel_changed (GtkAccelGroup *accel_group, GClosure *accel_closure, GtkWidget *widget) { - GNSMenuItem *cocoa_item = cocoa_menu_item_get (widget); + GNSMenuItem *cocoa_item; GtkWidget *label; + if (_exiting) + return; + + cocoa_item = cocoa_menu_item_get (widget); get_menu_label_text (widget, &label); if (GTK_IS_ACCEL_LABEL (label) && @@ -945,7 +951,12 @@ cocoa_menu_item_notify_label (GObject *object, GParamSpec *pspec, gpointer data) { - GNSMenuItem *cocoa_item = cocoa_menu_item_get (GTK_WIDGET (object)); + GNSMenuItem *cocoa_item; + + if (_exiting) + return; + + cocoa_item = cocoa_menu_item_get (GTK_WIDGET (object)); if (!strcmp (pspec->name, "label")) { @@ -964,6 +975,9 @@ cocoa_menu_item_notify (GObject *object, GParamSpec *pspec, NSMenuItem *cocoa_item) { + if (_exiting) + return; + if (!strcmp (pspec->name, "sensitive") || !strcmp (pspec->name, "visible")) { @@ -1449,10 +1463,18 @@ gtk_application_ready () extern "C" void gtk_application_cleanup() { - if (_window_menu) + _exiting = 1; + + if (_window_menu) { [ _window_menu release ]; - if (_app_menu) + _window_menu = 0; + } + if (_app_menu) { [ _app_menu release ]; - if (_main_menubar) + _app_menu = 0; + } + if (_main_menubar) { [ _main_menubar release ]; + _main_menubar = 0; + } } diff --git a/libs/gtkmm2ext/gtkmm2ext/application.h b/libs/gtkmm2ext/gtkmm2ext/application.h new file mode 100644 index 0000000000..3fb107b783 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/application.h @@ -0,0 +1,63 @@ +/* GTK+ Integration with platform-specific application-wide features + * such as the OS X menubar and application delegate concepts. + * + * Copyright (C) 2009 Paul Davis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GTK_APPLICATION_MM_H__ +#define __GTK_APPLICATION_MM_H__ + +#include // for GtkApplicationGroup typedef +#include + +namespace Gtk { + class MenuItem; + class MenuShell; +} + +namespace Glib { + class ustring; +} + +namespace Gtkmm2ext { + +class Application +{ +public: + static Application* instance(); + ~Application (); + + void ready (); + void cleanup (); + void set_menu_bar (Gtk::MenuShell&); + GtkApplicationMenuGroup* add_app_menu_group (); + void add_app_menu_item (GtkApplicationMenuGroup*, Gtk::MenuItem*); + + sigc::signal ActivationChanged; + sigc::signal ShouldLoad; + sigc::signal ShouldQuit; + +private: + Application (); + + static Application* _instance; +}; + +} + +#endif /* __GTK_APPLICATION_MM_H__ */ diff --git a/libs/gtkmm2ext/wscript b/libs/gtkmm2ext/wscript index ca4682a0f1..2fc711fc73 100644 --- a/libs/gtkmm2ext/wscript +++ b/libs/gtkmm2ext/wscript @@ -20,6 +20,7 @@ VERSION = GTKMM2EXT_VERSION gtkmm2ext_sources = [ 'actions.cc', + 'application.cc', 'auto_spin.cc', 'barcontroller.cc', 'binding_proxy.cc', diff --git a/wscript b/wscript index cd417b7ad4..6ac723a313 100644 --- a/wscript +++ b/wscript @@ -384,7 +384,7 @@ def configure(conf): autowaf.configure(conf) gcc_versions = fetch_gcc_version() - if Options.options.debug and gcc_versions[0] == '4' and gcc_versions[1] > '4': + if not Options.options.debug and gcc_versions[0] == '4' and gcc_versions[1] > '4': print 'Version 4.5 of gcc is not ready for use when compiling Ardour with optimization.' print 'Please use a different version or re-configure with --debug' exit (1)