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
22 #include "ardour_ui.h"
25 #include "sync-menu.h"
27 #include <Appkit/Appkit.h>
29 sigc::signal<void,bool> ApplicationActivationChanged;
30 static EventHandlerRef application_event_handler_ref;
32 /* Called for clicks on the dock icon. Can be used to unminimize or
33 * create a new window for example.
37 handle_reopen_application (const AppleEvent *inAppleEvent,
38 AppleEvent *outAppleEvent,
41 cerr << "reopen app\n";
46 handle_quit_application (const AppleEvent *inAppleEvent,
47 AppleEvent *outAppleEvent,
51 ARDOUR_UI::instance()->quit ();
57 application_event_handler (EventHandlerCallRef nextHandlerRef, EventRef event, void *userData)
59 UInt32 eventKind = GetEventKind (event);
62 case kEventAppActivated:
63 ApplicationActivationChanged (true); // EMIT SIGNAL
64 return eventNotHandledErr;
66 case kEventAppDeactivated:
67 ApplicationActivationChanged (false); // EMIT SIGNAL
68 return eventNotHandledErr;
71 // pass-thru all kEventClassApplication events we're not interested in.
74 return eventNotHandledErr;
78 ARDOUR_UI::platform_specific ()
80 AEInstallEventHandler (kCoreEventClass, kAEReopenApplication,
81 handle_reopen_application, 0, true);
83 AEInstallEventHandler (kCoreEventClass, kAEQuitApplication,
84 handle_quit_application, 0, true);
86 Gtk::Widget* widget = ActionManager::get_widget ("/ui/Main/Session/Quit");
88 ige_mac_menu_set_quit_menu_item ((GtkMenuItem*) widget->gobj());
91 IgeMacMenuGroup* group = ige_mac_menu_add_app_menu_group ();
93 widget = ActionManager::get_widget ("/ui/Main/Session/About");
95 ige_mac_menu_add_app_menu_item (group, (GtkMenuItem*) widget->gobj(), 0);
97 widget = ActionManager::get_widget ("/ui/Main/Session/ToggleOptionsEditor");
99 ige_mac_menu_add_app_menu_item (group, (GtkMenuItem*) widget->gobj(), 0);
102 EventTypeSpec applicationEventTypes[] = {
103 {kEventClassApplication, kEventAppActivated },
104 {kEventClassApplication, kEventAppDeactivated }
107 EventHandlerUPP ehUPP = NewEventHandlerUPP (application_event_handler);
109 InstallApplicationEventHandler (ehUPP, sizeof(applicationEventTypes) / sizeof(EventTypeSpec),
110 applicationEventTypes, 0, &application_event_handler_ref);
114 ARDOUR_UI::platform_setup ()
116 if (!ARDOUR_COMMAND_LINE::finder_invoked_ardour) {
118 /* if invoked from the command line, make sure we're visible */
120 [NSApp activateIgnoringOtherApps:YES];