summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-01-15 01:59:56 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-01-15 01:59:56 +0000
commit15bb3b577ec9a8cb50758c4b017718e342a2439c (patch)
tree293407ebe738cfc3378335a82cb69e75751e9e73 /gtk2_ardour
parent496a2da48f8a02a4be7761f0da6eb0b3828ee68b (diff)
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
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour_ui_ed.cc6
-rw-r--r--gtk2_ardour/cocoacarbon.mm33
-rw-r--r--gtk2_ardour/utils.cc54
3 files changed, 40 insertions, 53 deletions
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 <gtkmm2ext/sync-menu.h>
-#endif
+#include <gtkmm2ext/gtkapplication.h>
#include <ardour/session.h>
#include <ardour/profile.h>
@@ -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 <Carbon/Carbon.h> // bring it in early
-#undef check // nuke this stupidity
-#define APPLE_SAYS_YES YES
-#undef YES // and this
-#undef NO // and this
+#include <gtkmm2ext/gtkapplication.h>
+#include <gdk/gdkquartz.h>
+#undef check
+#undef YES
+#undef NO
#include "ardour_ui.h"
#include "actions.h"
#include "opts.h"
-#include <gtkmm2ext/sync-menu.h>
-#include <gdk/gdkquartz.h>
sigc::signal<void,bool> ApplicationActivationChanged;
@@ -74,7 +72,12 @@ sigc::signal<void,bool> 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);
}