From 15bb3b577ec9a8cb50758c4b017718e342a2439c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 15 Jan 2010 01:59:56 +0000 Subject: rework "ige_mac" menubar integration from Carbon to Cocoa; recast as start of GtkApplication object as per discussions on #gtk+; associated changes in ardour; NOT TESTED ON X11, LEOPARD or SNOW LEOPARD git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6493 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui_ed.cc | 6 ++--- gtk2_ardour/cocoacarbon.mm | 33 ++++++++++++--------------- gtk2_ardour/utils.cc | 54 ++++++++++++++++++++------------------------- 3 files changed, 40 insertions(+), 53 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index fc0fddbb8d..b795bc5ae8 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -41,9 +41,7 @@ #include "mixer_ui.h" #include "utils.h" -#ifdef GTKOSX -#include -#endif +#include #include #include @@ -854,7 +852,7 @@ void ARDOUR_UI::use_menubar_as_top_menubar () { #ifdef GTKOSX - ige_mac_menu_set_menu_bar ((GtkMenuShell*) menu_bar->gobj()); + gtk_application_set_menu_bar ((GtkMenuShell*) menu_bar->gobj()); // ige_mac_menu_set_quit_menu_item (some_item->gobj()); #endif } diff --git a/gtk2_ardour/cocoacarbon.mm b/gtk2_ardour/cocoacarbon.mm index c39bbe5ed9..ddf1f26f9f 100644 --- a/gtk2_ardour/cocoacarbon.mm +++ b/gtk2_ardour/cocoacarbon.mm @@ -16,17 +16,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include // bring it in early -#undef check // nuke this stupidity -#define APPLE_SAYS_YES YES -#undef YES // and this -#undef NO // and this +#include +#include +#undef check +#undef YES +#undef NO #include "ardour_ui.h" #include "actions.h" #include "opts.h" -#include -#include sigc::signal ApplicationActivationChanged; @@ -74,7 +72,12 @@ sigc::signal ApplicationActivationChanged; { Glib::ustring utf8_path ([file UTF8String]); ARDOUR_UI::instance()->idle_load (utf8_path); - return APPLE_SAYS_YES; + return 1; +} +- (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender +{ + Gtkmm2ext::UI::instance()->quit (); + return NSTerminateCancel; } @end @@ -83,23 +86,16 @@ ARDOUR_UI::platform_specific () { Gtk::Widget* widget; - cerr << "Plaform specific GUI stuff\n"; - - widget = ActionManager::get_widget ("/ui/Main/Session/Quit"); - if (widget) { - ige_mac_menu_set_quit_menu_item ((GtkMenuItem*) widget->gobj()); - } - - IgeMacMenuGroup* group = ige_mac_menu_add_app_menu_group (); + GtkApplicationMenuGroup* group = gtk_application_add_app_menu_group (); widget = ActionManager::get_widget ("/ui/Main/Help/About"); if (widget) { - ige_mac_menu_add_app_menu_item (group, (GtkMenuItem*) widget->gobj(), 0); + gtk_application_add_app_menu_item (group, (GtkMenuItem*) widget->gobj(), 0); } widget = ActionManager::get_widget ("/ui/Main/WindowMenu/ToggleOptionsEditor"); if (widget) { - ige_mac_menu_add_app_menu_item (group, (GtkMenuItem*) widget->gobj(), 0); + gtk_application_add_app_menu_item (group, (GtkMenuItem*) widget->gobj(), 0); } [ NSApp finishLaunching ]; @@ -118,7 +114,6 @@ ARDOUR_UI::platform_setup () /* this will stick around for ever ... is that OK ? */ [ [AppNotificationObject alloc] init]; - [ NSApp setDelegate: [ArdourApplicationDelegate new]]; } diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 49bd38b6f4..22b6cfa9d5 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -400,12 +400,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) { @@ -424,7 +418,7 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) bool special_handling_of_unmodified_accelerators = false; bool allow_activating = true; -#undef DEBUG_ACCELERATOR_HANDLING +#define DEBUG_ACCELERATOR_HANDLING #ifdef DEBUG_ACCELERATOR_HANDLING //bool debug = (getenv ("ARDOUR_DEBUG_ACCELERATOR_HANDLING") != 0); bool debug=true; @@ -447,7 +441,13 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) #ifdef DEBUG_ACCELERATOR_HANDLING if (debug) { - cerr << "Win = " << win << " Key event: code = " << ev->keyval << " state = " << hex << ev->state << dec << " special handling ? " + cerr << "Win = " << win << " Key event: code = " << ev->keyval << " name = " << gdk_keyval_name (ev->keyval) << " state = " << hex << ev->state << dec + << " ctrl " << ((ev->state & GDK_CONTROL_MASK) ? 1 : 0) + << " alt " << ((ev->state & GDK_MOD1_MASK) ? 1 : 0) + << " shift " << ((ev->state & GDK_SHIFT_MASK) ? 1 : 0) + << " cmd/meta " << ((ev->state & GDK_META_MASK) ? 1 : 0) + << " lock " << ((ev->state & GDK_LOCK_MASK) ? 1 : 0) + << " special handling ? " << special_handling_of_unmodified_accelerators << " magic widget focus ? " << Keyboard::some_magic_widget_has_focus() @@ -499,20 +499,19 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev) uint32_t fakekey = ev->keyval; if (possibly_translate_keyval_to_make_legal_accelerator (fakekey)) { - if (allow_activating && gtk_accel_groups_activate(G_OBJECT(win), fakekey, GdkModifierType(ev->state))) { - return true; +#ifdef DEBUG_ACCELERATOR_HANDLING + if (debug) { + cerr << "\tactivate without special handling of unmodified accels\n"; } - -#ifdef GTKOSX - if (allow_activating) { - int oldval = ev->keyval; - ev->keyval = fakekey; - if (gdk_quartz_possibly_forward ((GdkEvent*) ev)) { - return true; +#endif + if (allow_activating && gtk_accel_groups_activate(G_OBJECT(win), fakekey, GdkModifierType(ev->state))) { +#ifdef DEBUG_ACCELERATOR_HANDLING + if (debug) { + cerr << "\tactivation handled key\n"; } - ev->keyval = oldval; - } #endif + return true; + } } } @@ -531,12 +530,13 @@ 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)) { +#ifdef DEBUG_ACCELERATOR_HANDLING + if (debug) { + cerr << "\tactivation handled key\n"; + } +#endif + return true; } } @@ -564,12 +564,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); } -- cgit v1.2.3