2 Copyright (C) 2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include <Carbon/Carbon.h>
20 #undef check // stupid, stupid carbon
21 #undef YES // stupid, stupid gtkmm and/or NSObjC
24 #include "ardour_ui.h"
27 #include "sync-menu.h"
29 #include <Appkit/Appkit.h>
31 sigc::signal<void,bool> ApplicationActivationChanged;
32 static EventHandlerRef application_event_handler_ref;
34 /* Called for clicks on the dock icon. Can be used to unminimize or
35 * create a new window for example.
39 handle_reopen_application (const AppleEvent *inAppleEvent,
40 AppleEvent *outAppleEvent,
43 cerr << "reopen app\n";
48 handle_quit_application (const AppleEvent *inAppleEvent,
49 AppleEvent *outAppleEvent,
53 ARDOUR_UI::instance()->quit ();
59 application_event_handler (EventHandlerCallRef nextHandlerRef, EventRef event, void *userData)
61 UInt32 eventKind = GetEventKind (event);
64 case kEventAppActivated:
65 ApplicationActivationChanged (true); // EMIT SIGNAL
66 return eventNotHandledErr;
68 case kEventAppDeactivated:
69 ApplicationActivationChanged (false); // EMIT SIGNAL
70 return eventNotHandledErr;
73 // pass-thru all kEventClassApplication events we're not interested in.
76 return eventNotHandledErr;
80 ARDOUR_UI::platform_specific ()
82 AEInstallEventHandler (kCoreEventClass, kAEReopenApplication,
83 handle_reopen_application, 0, true);
85 AEInstallEventHandler (kCoreEventClass, kAEQuitApplication,
86 handle_quit_application, 0, true);
88 Gtk::Widget* widget = ActionManager::get_widget ("/ui/Main/Session/Quit");
90 ige_mac_menu_set_quit_menu_item ((GtkMenuItem*) widget->gobj());
93 IgeMacMenuGroup* group = ige_mac_menu_add_app_menu_group ();
95 widget = ActionManager::get_widget ("/ui/Main/Session/About");
97 ige_mac_menu_add_app_menu_item (group, (GtkMenuItem*) widget->gobj(), 0);
99 widget = ActionManager::get_widget ("/ui/Main/Session/ToggleOptionsEditor");
101 ige_mac_menu_add_app_menu_item (group, (GtkMenuItem*) widget->gobj(), 0);
104 EventTypeSpec applicationEventTypes[] = {
105 {kEventClassApplication, kEventAppActivated },
106 {kEventClassApplication, kEventAppDeactivated }
109 EventHandlerUPP ehUPP = NewEventHandlerUPP (application_event_handler);
111 InstallApplicationEventHandler (ehUPP, sizeof(applicationEventTypes) / sizeof(EventTypeSpec),
112 applicationEventTypes, 0, &application_event_handler_ref);
116 ARDOUR_UI::platform_setup ()
118 if (!ARDOUR_COMMAND_LINE::finder_invoked_ardour) {
120 /* if invoked from the command line, make sure we're visible */
122 [NSApp activateIgnoringOtherApps:1];