forward port 2.X changes up to and including rev 6842
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 17 Aug 2010 02:48:24 +0000 (02:48 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 17 Aug 2010 02:48:24 +0000 (02:48 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7637 d708f5d6-7413-0410-9779-e7cbd77b26cf

12 files changed:
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/crossfade_edit.cc
gtk2_ardour/main.cc
libs/ardour/crossfade.cc
libs/gtkmm2ext/application.cc [new file with mode: 0644]
libs/gtkmm2ext/gtk_ui.cc
libs/gtkmm2ext/gtkapplication_quartz.mm
libs/gtkmm2ext/gtkmm2ext/application.h [new file with mode: 0644]
libs/gtkmm2ext/wscript
wscript

index 388af952004b76e47b1edb787a10c44dc38c5f30..dd6da1e24657c54e5cfa8eded95bbd717bc00291 100644 (file)
@@ -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 ()
 {
index 20660307cc3bc2f28b1bddb0b6a4d06327625932..cccc4ab5b015fe7be59972b87ce7650c9ec9d911 100644 (file)
@@ -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 ();
 
index 4e02d48f9fdb0f041987a091c1010003f952f9d1..efdbd13add09738f4f2e0f1821860cbc23bf95fa 100644 (file)
@@ -48,9 +48,7 @@
 #include "startup.h"
 #include "utils.h"
 
-#ifdef GTKOSX
-#include <gtkmm2ext/sync-menu.h>
-#endif
+#include <gtkmm2ext/application.h>
 
 #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
index ecb7b8a1f864e2e8bb56dabc75f790109d1558fb..b6dcf07920be36a332df1ecec14569e3fec8a3fe 100644 (file)
@@ -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 ();
index a512af74a3dd771b576179140390960585ecf59f..c17d39d2a2a609f7df082417615b45b8f2bec507 100644 (file)
@@ -39,6 +39,7 @@
 #include "ardour/filesystem_paths.h"
 
 #include <gtkmm/main.h>
+#include <gtkmm2ext/application.h>
 #include <gtkmm2ext/popup.h>
 #include <gtkmm2ext/utils.h>
 
@@ -439,6 +440,7 @@ int main (int argc, char *argv[])
        }
 
        ui->run (text_receiver);
+        Gtkmm2ext::Application::instance()->cleanup();
        ui = 0;
 
        ARDOUR::cleanup ();
index 40857bd56afa5c45fab13f6022904c4213ed5eb8..aa203c3940a8507ffab6d8a4ae264e73c334b2b6 100644 (file)
@@ -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 (file)
index 0000000..54efb47
--- /dev/null
@@ -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 <gtkmm/menushell.h>
+#include <gtkmm/menuitem.h>
+
+#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());
+}
index 456b8e29c8948940110ab0c776136286e3525e5d..d1ef1e27c42b6872e23f8eb1e7d4eea50789c3f3 100644 (file)
@@ -33,6 +33,7 @@
 #include <pbd/pthread_utils.h>
 #include <pbd/stacktrace.h>
 
+#include <gtkmm2ext/application.h>
 #include <gtkmm2ext/gtk_ui.h>
 #include <gtkmm2ext/textviewer.h>
 #include <gtkmm2ext/popup.h>
@@ -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;
index b6d6b71d5d39202e7e1c78d133604d000485c551..c5fb8b12e23c41c2857c17dd35655dd7745789ab 100644 (file)
@@ -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 (file)
index 0000000..3fb107b
--- /dev/null
@@ -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 <gtkmm2ext/gtkapplication.h> // for GtkApplicationGroup typedef
+#include <sigc++/signal.h>
+
+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<void,bool>                 ActivationChanged;
+    sigc::signal<void,const Glib::ustring&> ShouldLoad;
+    sigc::signal<void>                      ShouldQuit;
+
+private:
+    Application ();
+
+    static Application* _instance;
+};
+
+}
+
+#endif /* __GTK_APPLICATION_MM_H__ */
index ca4682a0f1300986d0ea7ab10bdc2de0f16cc34a..2fc711fc73685a372685ed8ac19f9ce60bd689d1 100644 (file)
@@ -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 cd417b7ad4b96a68deddbc21b2b78c7b0bbc9627..6ac723a313bdccc84c1cac78392cc99c98684725 100644 (file)
--- 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)