remove AU GUI debugging test in which arrow keys could be used to change GUI size
[ardour.git] / gtk2_ardour / au_pluginui.mm
1 #include <gtkmm/stock.h>
2
3 #undef  Marker
4 #define Marker FuckYouAppleAndYourLackOfNameSpaces
5
6 #include "pbd/convert.h"
7 #include "pbd/error.h"
8
9 #include "ardour/audio_unit.h"
10 #include "ardour/debug.h"
11 #include "ardour/plugin_insert.h"
12
13 #undef check // stupid gtk, stupid apple
14
15 #include <gtkmm/button.h>
16 #include <gdk/gdkquartz.h>
17
18 #include <gtkmm2ext/utils.h>
19
20 #include "au_pluginui.h"
21 #include "gui_thread.h"
22
23 #include "appleutility/CAAudioUnit.h"
24 #include "appleutility/CAComponent.h"
25
26 #import <AudioUnit/AUCocoaUIView.h>
27 #import <CoreAudioKit/AUGenericView.h>
28
29 #undef Marker
30
31 #include "keyboard.h"
32 #include "utils.h"
33 #include "public_editor.h"
34 #include "i18n.h"
35
36 using namespace ARDOUR;
37 using namespace Gtk;
38 using namespace Gtkmm2ext;
39 using namespace sigc;
40 using namespace std;
41 using namespace PBD;
42
43 vector<string> AUPluginUI::automation_mode_strings;
44
45 static const gchar* _automation_mode_strings[] = {
46         X_("Manual"),
47         X_("Play"),
48         X_("Write"),
49         X_("Touch"),
50         0
51 };
52
53 @implementation NotificationObject
54
55 - (NotificationObject*) initWithPluginUI: (AUPluginUI*) apluginui andCocoaParent: (NSWindow*) cp andTopLevelParent: (NSWindow*) tlp
56 {
57         self = [ super init ];
58
59         if (self) {
60                 plugin_ui = apluginui; 
61                 top_level_parent = tlp;
62                 
63                 if (cp) {
64                         cocoa_parent = cp;
65                         
66                         [[NSNotificationCenter defaultCenter] addObserver:self
67                          selector:@selector(cocoaParentActivationHandler:)
68                          name:NSWindowDidBecomeMainNotification
69                          object:nil];
70                         
71                         [[NSNotificationCenter defaultCenter] addObserver:self
72                          selector:@selector(cocoaParentBecameKeyHandler:)
73                          name:NSWindowDidBecomeKeyNotification
74                          object:nil];
75                 }
76         }
77
78         return self;
79 }
80                 
81 - (void)cocoaParentActivationHandler:(NSNotification *)notification
82 {
83         NSWindow* notification_window = (NSWindow *)[notification object];
84
85         if (top_level_parent == notification_window || cocoa_parent == notification_window) {
86                 if ([notification_window isMainWindow]) {
87                         plugin_ui->activate();
88                 } else {
89                         plugin_ui->deactivate();
90                 }
91         } 
92 }
93
94 - (void)cocoaParentBecameKeyHandler:(NSNotification *)notification
95 {
96         NSWindow* notification_window = (NSWindow *)[notification object];
97
98         if (top_level_parent == notification_window || cocoa_parent == notification_window) {
99                 if ([notification_window isKeyWindow]) {
100                         plugin_ui->activate();
101                 } else {
102                         plugin_ui->deactivate();
103                 }
104         } 
105 }
106
107 - (void)auViewResized:(NSNotification *)notification;
108 {
109         (void) notification; // stop complaints about unusued argument
110         plugin_ui->cocoa_view_resized();
111 }
112
113 @end
114
115 AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
116         : PlugUIBase (insert)
117         , automation_mode_label (_("Automation"))
118         , preset_label (_("Presets"))
119         
120 {
121         if (automation_mode_strings.empty()) {
122                 automation_mode_strings = I18N (_automation_mode_strings);
123         }
124         
125         set_popdown_strings (automation_mode_selector, automation_mode_strings);
126         automation_mode_selector.set_active_text (automation_mode_strings.front());
127
128         if ((au = boost::dynamic_pointer_cast<AUPlugin> (insert->plugin())) == 0) {
129                 error << _("unknown type of editor-supplying plugin (note: no AudioUnit support in this version of ardour)") << endmsg;
130                 throw failed_constructor ();
131         }
132
133         /* stuff some stuff into the top of the window */
134
135         HBox* smaller_hbox = manage (new HBox);
136
137         smaller_hbox->set_spacing (6);
138         smaller_hbox->pack_start (preset_label, false, false, 4);
139         smaller_hbox->pack_start (_preset_combo, false, false);
140         smaller_hbox->pack_start (save_button, false, false);
141 #if 0
142         /* one day these might be useful with an AU plugin, but not yet */
143         smaller_hbox->pack_start (automation_mode_label, false, false);
144         smaller_hbox->pack_start (automation_mode_selector, false, false);
145 #endif
146         smaller_hbox->pack_start (bypass_button, false, true);
147
148         VBox* v1_box = manage (new VBox);
149         VBox* v2_box = manage (new VBox);
150
151         v1_box->pack_start (*smaller_hbox, false, true);
152         v2_box->pack_start (focus_button, false, true);
153
154         top_box.set_homogeneous (false);
155         top_box.set_spacing (6);
156         top_box.set_border_width (6);
157
158         top_box.pack_end (*v2_box, false, false);
159         top_box.pack_end (*v1_box, false, false);
160
161         set_spacing (6);
162         pack_start (top_box, false, false);
163         pack_start (low_box, false, false);
164
165         preset_label.show ();
166         _preset_combo.show ();
167         automation_mode_label.show ();
168         automation_mode_selector.show ();
169         bypass_button.show ();
170         top_box.show ();
171         low_box.show ();
172
173         _activating_from_app = false;
174         cocoa_parent = 0;
175         _notify = 0;
176         cocoa_window = 0;
177         carbon_window = 0;
178         au_view = 0;
179         editView = 0;
180
181         /* prefer cocoa, fall back to cocoa, but use carbon if its there */
182
183         if (test_cocoa_view_support()) {
184                 create_cocoa_view ();
185 #ifdef WITH_CARBON
186         } else if (test_carbon_view_support()) {
187                 create_carbon_view ();
188 #endif
189         } else {
190                 create_cocoa_view ();
191         }
192
193         low_box.signal_realize().connect (mem_fun (this, &AUPluginUI::lower_box_realized));
194 }
195
196 AUPluginUI::~AUPluginUI ()
197 {
198         if (cocoa_parent) {
199                 NSWindow* win = get_nswindow();
200                 [[NSNotificationCenter defaultCenter] removeObserver:_notify];
201                 [win removeChildWindow:cocoa_parent];
202
203         } 
204
205 #ifdef WITH_CARBON
206         if (carbon_window) {
207                 /* not parented, just overlaid on top of our window */
208                 DisposeWindow (carbon_window);
209         }
210 #endif
211
212         if (editView) {
213                 CloseComponent (editView);
214         }
215
216         if (au_view) {
217                 /* remove whatever we packed into low_box so that GTK doesn't
218                    mess with it.
219                 */
220
221                 [au_view removeFromSuperview];
222         }
223 }
224
225 bool
226 AUPluginUI::test_carbon_view_support ()
227 {
228         bool ret = false;
229         
230         carbon_descriptor.componentType = kAudioUnitCarbonViewComponentType;
231         carbon_descriptor.componentSubType = 'gnrc';
232         carbon_descriptor.componentManufacturer = 'appl';
233         carbon_descriptor.componentFlags = 0;
234         carbon_descriptor.componentFlagsMask = 0;
235         
236         OSStatus err;
237
238         // ask the AU for its first editor component
239         UInt32 propertySize;
240         err = AudioUnitGetPropertyInfo(*au->get_au(), kAudioUnitProperty_GetUIComponentList, kAudioUnitScope_Global, 0, &propertySize, NULL);
241         if (!err) {
242                 int nEditors = propertySize / sizeof(ComponentDescription);
243                 ComponentDescription *editors = new ComponentDescription[nEditors];
244                 err = AudioUnitGetProperty(*au->get_au(), kAudioUnitProperty_GetUIComponentList, kAudioUnitScope_Global, 0, editors, &propertySize);
245                 if (!err) {
246                         // just pick the first one for now
247                         carbon_descriptor = editors[0];
248                         ret = true;
249                 }
250                 delete[] editors;
251         }
252
253         return ret;
254 }
255         
256 bool
257 AUPluginUI::test_cocoa_view_support ()
258 {
259         UInt32 dataSize   = 0;
260         Boolean isWritable = 0;
261         OSStatus err = AudioUnitGetPropertyInfo(*au->get_au(),
262                                                 kAudioUnitProperty_CocoaUI, kAudioUnitScope_Global,
263                                                 0, &dataSize, &isWritable);
264         
265         return dataSize > 0 && err == noErr;
266 }
267
268 bool
269 AUPluginUI::plugin_class_valid (Class pluginClass)
270 {
271         if([pluginClass conformsToProtocol: @protocol(AUCocoaUIBase)]) {
272                 if([pluginClass instancesRespondToSelector: @selector(interfaceVersion)] &&
273                    [pluginClass instancesRespondToSelector: @selector(uiViewForAudioUnit:withSize:)]) {
274                                 return true;
275                 }
276         }
277         return false;
278 }
279
280 int
281 AUPluginUI::create_cocoa_view ()
282 {
283         BOOL wasAbleToLoadCustomView = NO;
284         AudioUnitCocoaViewInfo* cocoaViewInfo = NULL;
285         UInt32               numberOfClasses = 0;
286         UInt32     dataSize;
287         Boolean    isWritable;
288         NSString*           factoryClassName = 0;
289         NSURL*              CocoaViewBundlePath = NULL;
290
291         OSStatus result = AudioUnitGetPropertyInfo (*au->get_au(),
292                                                     kAudioUnitProperty_CocoaUI,
293                                                     kAudioUnitScope_Global, 
294                                                     0,
295                                                     &dataSize,
296                                                     &isWritable );
297
298         numberOfClasses = (dataSize - sizeof(CFURLRef)) / sizeof(CFStringRef);
299
300         // Does view have custom Cocoa UI?
301         
302         if ((result == noErr) && (numberOfClasses > 0) ) {
303
304                 DEBUG_TRACE(DEBUG::AudioUnits,
305                             string_compose ( "based on %1, there are %2 cocoa UI classes\n", dataSize, numberOfClasses));
306
307                 cocoaViewInfo = (AudioUnitCocoaViewInfo *)malloc(dataSize);
308
309                 if(AudioUnitGetProperty(*au->get_au(),
310                                         kAudioUnitProperty_CocoaUI,
311                                         kAudioUnitScope_Global,
312                                         0,
313                                         cocoaViewInfo,
314                                         &dataSize) == noErr) {
315
316                         CocoaViewBundlePath     = (NSURL *)cocoaViewInfo->mCocoaAUViewBundleLocation;
317                                 
318                         // we only take the first view in this example.
319                         factoryClassName        = (NSString *)cocoaViewInfo->mCocoaAUViewClass[0];
320                         
321                         DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("the factory name is %1 bundle is %2\n",
322                                                                         [factoryClassName UTF8String], CocoaViewBundlePath));
323                         
324                 } else {
325
326                         DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("No cocoaUI property cocoaViewInfo = %1\n", cocoaViewInfo));
327
328                         if (cocoaViewInfo != NULL) {
329                                 free (cocoaViewInfo);
330                                 cocoaViewInfo = NULL;
331                         }
332                 }
333         }
334
335         // [A] Show custom UI if view has it
336
337         if (CocoaViewBundlePath && factoryClassName) {
338                 NSBundle *viewBundle    = [NSBundle bundleWithPath:[CocoaViewBundlePath path]];
339
340                 DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("tried to create bundle, result = %1\n", viewBundle));
341
342                 if (viewBundle == nil) {
343                         error << _("AUPluginUI: error loading AU view's bundle") << endmsg;
344                         return -1;
345                 } else {
346                         Class factoryClass = [viewBundle classNamed:factoryClassName];
347                         DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("tried to create factory class, result = %1\n", factoryClass));
348                         if (!factoryClass) {
349                                 error << _("AUPluginUI: error getting AU view's factory class from bundle") << endmsg;
350                                 return -1;
351                         }
352                         
353                         // make sure 'factoryClass' implements the AUCocoaUIBase protocol
354                         if (!plugin_class_valid (factoryClass)) {
355                                 error << _("AUPluginUI: U view's factory class does not properly implement the AUCocoaUIBase protocol") << endmsg;
356                                 return -1;
357                         }
358                         // make a factory
359                         id factory = [[[factoryClass alloc] init] autorelease];
360                         if (factory == nil) {
361                                 error << _("AUPluginUI: Could not create an instance of the AU view factory") << endmsg;
362                                 return -1;
363                         }
364
365                         DEBUG_TRACE (DEBUG::AudioUnits, "got a factory instance\n");
366
367                         // make a view
368                         au_view = [factory uiViewForAudioUnit:*au->get_au() withSize:NSZeroSize];
369
370                         DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("view created @ %1\n", au_view));
371                         
372                         // cleanup
373                         [CocoaViewBundlePath release];
374                         if (cocoaViewInfo) {
375                                 UInt32 i;
376                                 for (i = 0; i < numberOfClasses; i++)
377                                         CFRelease(cocoaViewInfo->mCocoaAUViewClass[i]);
378                                 
379                                 free (cocoaViewInfo);
380                         }
381                         wasAbleToLoadCustomView = YES;
382                 }
383         }
384
385         if (!wasAbleToLoadCustomView) {
386                 // load generic Cocoa view
387                 DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("Loading generic view using %1 -> %2\n", au,
388                                                                 au->get_au()));
389                 au_view = [[AUGenericView alloc] initWithAudioUnit:*au->get_au()];
390                 DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("view created @ %1\n", au_view));
391                 [(AUGenericView *)au_view setShowsExpertParameters:YES];
392         }
393
394         // Get the initial size of the new AU View's frame 
395         
396         NSRect rect = [au_view frame];
397         low_box.set_size_request (rect.size.width, rect.size.height);
398         
399         return 0;
400 }
401
402 void
403 AUPluginUI::cocoa_view_resized ()
404 {
405         GtkRequisition topsize = top_box.size_request ();
406         NSWindow* window = get_nswindow ();
407         NSSize oldContentSize= [window contentRectForFrameRect:[window frame]].size;
408         NSSize newContentSize= [au_view frame].size;
409         NSRect windowFrame= [window frame];
410         
411         oldContentSize.height -= topsize.height;
412
413         float dy = oldContentSize.height - newContentSize.height;
414         float dx = oldContentSize.width - newContentSize.width;
415
416         windowFrame.origin.y    += dy;
417         windowFrame.origin.x    += dx;
418         windowFrame.size.height -= dy;
419         windowFrame.size.width  -= dx;
420         
421         [[NSNotificationCenter defaultCenter] removeObserver:_notify
422          name:NSViewFrameDidChangeNotification 
423          object:au_view];
424
425         NSUInteger old_auto_resize = [au_view autoresizingMask];
426
427         [au_view setAutoresizingMask:NSViewNotSizable];
428         [window setFrame:windowFrame display:YES];
429         [au_view setAutoresizingMask:old_auto_resize];
430
431         [[NSNotificationCenter defaultCenter] addObserver:_notify
432          selector:@selector(auViewResized:) name:NSViewFrameDidChangeNotification
433          object:au_view];
434 }
435
436 int
437 AUPluginUI::create_carbon_view ()
438 {
439 #ifdef WITH_CARBON
440         OSStatus err;
441         ControlRef root_control;
442
443         Component editComponent = FindNextComponent(NULL, &carbon_descriptor);
444         
445         OpenAComponent(editComponent, &editView);
446         if (!editView) {
447                 error << _("AU Carbon view: cannot open AU Component") << endmsg;
448                 return -1;
449         }
450         
451         Rect r = { 100, 100, 100, 100 };
452         WindowAttributes attr = WindowAttributes (kWindowStandardHandlerAttribute |
453                                                   kWindowCompositingAttribute|
454                                                   kWindowNoShadowAttribute|
455                                                   kWindowNoTitleBarAttribute);
456
457         if ((err = CreateNewWindow(kDocumentWindowClass, attr, &r, &carbon_window)) != noErr) {
458                 error << string_compose (_("AUPluginUI: cannot create carbon window (err: %1)"), err) << endmsg;
459                 CloseComponent (editView);
460                 return -1;
461         }
462         
463         if ((err = GetRootControl(carbon_window, &root_control)) != noErr) {
464                 error << string_compose (_("AUPlugin: cannot get root control of carbon window (err: %1)"), err) << endmsg;
465                 DisposeWindow (carbon_window);
466                 CloseComponent (editView);
467                 return -1;
468         }
469
470         ControlRef viewPane;
471         Float32Point location  = { 0.0, 0.0 };
472         Float32Point size = { 0.0, 0.0 } ;
473
474         if ((err = AudioUnitCarbonViewCreate (editView, *au->get_au(), carbon_window, root_control, &location, &size, &viewPane)) != noErr) {
475                 error << string_compose (_("AUPluginUI: cannot create carbon plugin view (err: %1)"), err) << endmsg;
476                 DisposeWindow (carbon_window);
477                 CloseComponent (editView);
478                 return -1;
479         }
480
481         // resize window
482
483         Rect bounds;
484         GetControlBounds(viewPane, &bounds);
485         size.x = bounds.right-bounds.left;
486         size.y = bounds.bottom-bounds.top;
487
488         prefwidth = (int) (size.x + 0.5);
489         prefheight = (int) (size.y + 0.5);
490
491         SizeWindow (carbon_window, prefwidth, prefheight,  true);
492         low_box.set_size_request (prefwidth, prefheight);
493
494         return 0;
495 #else
496         error << _("AU Carbon GUI is not supported.") << endmsg;
497         return -1;
498 #endif
499 }
500
501 NSWindow*
502 AUPluginUI::get_nswindow ()
503 {
504         Gtk::Container* toplevel = get_toplevel();
505
506         if (!toplevel || !toplevel->is_toplevel()) {
507                 error << _("AUPluginUI: no top level window!") << endmsg;
508                 return 0;
509         }
510
511         NSWindow* true_parent = gdk_quartz_window_get_nswindow (toplevel->get_window()->gobj());
512
513         if (!true_parent) {
514                 error << _("AUPluginUI: no top level window!") << endmsg;
515                 return 0;
516         }
517
518         return true_parent;
519 }
520
521 void
522 AUPluginUI::activate ()
523 {
524 #ifdef WITH_CARBON
525         ActivateWindow (carbon_window, TRUE);
526 #endif
527         // [cocoa_parent makeKeyAndOrderFront:nil];
528 }
529
530 void
531 AUPluginUI::deactivate ()
532 {
533 #ifdef WITH_CARBON
534         ActivateWindow (carbon_window, FALSE);
535 #endif
536 }
537
538 int
539 AUPluginUI::parent_carbon_window ()
540 {
541 #ifdef WITH_CARBON
542         NSWindow* win = get_nswindow ();
543         int x, y;
544
545         if (!win) {
546                 return -1;
547         }
548
549         Gtk::Container* toplevel = get_toplevel();
550
551         if (!toplevel || !toplevel->is_toplevel()) {
552                 error << _("AUPluginUI: no top level window!") << endmsg;
553                 return -1;
554         }
555         
556         toplevel->get_window()->get_root_origin (x, y);
557
558         /* compute how tall the title bar is, because we have to offset the position of the carbon window
559            by that much.
560         */
561
562         NSRect content_frame = [NSWindow contentRectForFrameRect:[win frame] styleMask:[win styleMask]];
563         NSRect wm_frame = [NSWindow frameRectForContentRect:content_frame styleMask:[win styleMask]];
564
565         int titlebar_height = wm_frame.size.height - content_frame.size.height;
566
567         int packing_extra = 6; // this is the total vertical packing in our top level window
568
569         MoveWindow (carbon_window, x, y + titlebar_height + top_box.get_height() + packing_extra, false);
570         ShowWindow (carbon_window);
571
572         // create the cocoa window for the carbon one and make it visible
573         cocoa_parent = [[NSWindow alloc] initWithWindowRef: carbon_window];
574
575         SetWindowActivationScope (carbon_window, kWindowActivationScopeNone);
576
577         _notify = [ [NotificationObject alloc] initWithPluginUI:this andCocoaParent:cocoa_parent andTopLevelParent:win ]; 
578
579         [win addChildWindow:cocoa_parent ordered:NSWindowAbove];
580
581         return 0;
582 #else
583         return -1;
584 #endif
585 }       
586
587 int
588 AUPluginUI::parent_cocoa_window ()
589 {
590         NSWindow* win = get_nswindow ();
591
592         if (!win) {
593                 return -1;
594         }
595
596         [win setAutodisplay:YES]; // turn of GTK stuff for this window
597
598         Gtk::Container* toplevel = get_toplevel();
599
600         if (!toplevel || !toplevel->is_toplevel()) {
601                 error << _("AUPluginUI: no top level window!") << endmsg;
602                 return -1;
603         }
604
605         NSView* view = gdk_quartz_window_get_nsview (get_toplevel()->get_window()->gobj());
606         GtkRequisition a = top_box.size_request ();
607
608         /* move the au_view down so that it doesn't overlap the top_box contents */
609
610         NSPoint origin = { 0, a.height };
611
612         [au_view setFrameOrigin:origin];
613         [view addSubview:au_view positioned:NSWindowBelow relativeTo:nil]; 
614
615         // watch for size changes of the view
616
617         _notify = [ [NotificationObject alloc] initWithPluginUI:this andCocoaParent:nil andTopLevelParent:win ]; 
618
619         [[NSNotificationCenter defaultCenter] addObserver:_notify
620          selector:@selector(auViewResized:) name:NSViewFrameDidChangeNotification
621          object:au_view];
622
623         return 0;
624 }
625
626 static void
627 dump_view_tree (NSView* view, int depth)
628 {
629         NSArray* subviews = [view subviews];
630         unsigned long cnt = [subviews count];
631
632         for (int d = 0; d < depth; d++) {
633                 cerr << '\t';
634         }
635         cerr << " view @ " << view << endl;
636         
637         for (unsigned long i = 0; i < cnt; ++i) {
638                 NSView* subview = [subviews objectAtIndex:i];
639                 dump_view_tree (subview, depth+1);
640         }
641 }
642
643 void
644 AUPluginUI::forward_key_event (GdkEventKey* ev)
645 {
646         NSEvent* nsevent = gdk_quartz_event_get_nsevent ((GdkEvent*)ev);
647
648         if (au_view && nsevent) {
649
650                 /* filter on nsevent type here because GDK massages FlagsChanged
651                    messages into GDK_KEY_{PRESS,RELEASE} but Cocoa won't
652                    handle a FlagsChanged message as a keyDown or keyUp
653                 */
654
655                 if ([nsevent type] == NSKeyDown) {
656                         [[[au_view window] firstResponder] keyDown:nsevent];
657                 } else if ([nsevent type] == NSKeyUp) {
658                         [[[au_view window] firstResponder] keyUp:nsevent];
659                 } else if ([nsevent type] == NSFlagsChanged) {
660                         [[[au_view window] firstResponder] flagsChanged:nsevent];
661                 }
662         }
663 }
664
665 void
666 AUPluginUI::on_realize ()
667 {
668         VBox::on_realize ();
669
670         /* our windows should not have that resize indicator */
671
672         NSWindow* win = get_nswindow ();
673         if (win) {
674                 [win setShowsResizeIndicator:NO];
675         }
676 }
677
678 void
679 AUPluginUI::lower_box_realized ()
680 {
681         if (au_view) {
682                 parent_cocoa_window ();
683         } else if (carbon_window) {
684                 parent_carbon_window ();
685         }
686 }
687
688 bool
689 AUPluginUI::on_map_event (GdkEventAny*)
690 {
691         return false;
692 }
693
694 void
695 AUPluginUI::on_window_hide ()
696 {
697 #ifdef WITH_CARBON
698         if (carbon_window) {
699                 HideWindow (carbon_window);
700                 ActivateWindow (carbon_window, FALSE);
701         }
702 #endif
703
704         hide_all ();
705 }
706
707 bool
708 AUPluginUI::on_window_show (const string& /*title*/)
709 {
710         /* this is idempotent so just call it every time we show the window */
711
712         gtk_widget_realize (GTK_WIDGET(low_box.gobj()));
713
714         show_all ();
715
716 #ifdef WITH_CARBON
717         if (carbon_window) {
718                 ShowWindow (carbon_window);
719                 ActivateWindow (carbon_window, TRUE);
720         }
721 #endif
722
723         return true;
724 }
725
726 bool
727 AUPluginUI::start_updating (GdkEventAny*)
728 {
729         return false;
730 }
731
732 bool
733 AUPluginUI::stop_updating (GdkEventAny*)
734 {
735         return false;
736 }
737
738 PlugUIBase*
739 create_au_gui (boost::shared_ptr<PluginInsert> plugin_insert, VBox** box)
740 {
741         AUPluginUI* aup = new AUPluginUI (plugin_insert);
742         (*box) = aup;
743         return aup;
744 }
745
746 bool
747 AUPluginUI::on_focus_in_event (GdkEventFocus*)
748 {
749         //cerr << "au plugin focus in\n";
750         //Keyboard::magic_widget_grab_focus ();
751         return false;
752 }
753
754 bool
755 AUPluginUI::on_focus_out_event (GdkEventFocus*)
756 {
757         //cerr << "au plugin focus out\n";
758         //Keyboard::magic_widget_drop_focus ();
759         return false;
760 }
761