Remove unused code.
[ardour.git] / gtk2_ardour / vst_plugin_ui.cc
1 /*
2     Copyright (C) 2000-2010 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #include "ardour/vst_plugin.h"
21 #include "ardour/vst_types.h"
22 #include "vst_plugin_ui.h"
23 #include <gdk/gdkx.h>
24
25 VSTPluginUI::VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> insert, boost::shared_ptr<ARDOUR::VSTPlugin> plugin)
26         : PlugUIBase (insert)
27         , _vst (plugin)
28 {
29         Gtk::HBox* box = manage (new Gtk::HBox);
30         box->set_spacing (6);
31         box->set_border_width (6);
32         box->pack_end (focus_button, false, false);
33         box->pack_end (bypass_button, false, false, 10);
34         box->pack_end (delete_button, false, false);
35         box->pack_end (save_button, false, false);
36         box->pack_end (add_button, false, false);
37         box->pack_end (_preset_combo, false, false);
38
39         if (!insert->active ()) {
40                 bypass_button.set_active_state (Gtkmm2ext::Active);
41         } else {
42                 bypass_button.unset_active_state ();
43         }
44
45         pack_start (*box, false, false);
46         pack_start (_socket, true, true);
47 }
48
49 VSTPluginUI::~VSTPluginUI ()
50 {
51
52 }
53
54 void
55 VSTPluginUI::preset_selected ()
56 {
57         _socket.grab_focus ();
58         PlugUIBase::preset_selected ();
59 }
60
61 int
62 VSTPluginUI::get_preferred_height ()
63 {
64         return _vst->state()->height;
65 }
66
67 int
68 VSTPluginUI::get_preferred_width ()
69 {
70         return _vst->state()->width;
71 }
72
73 int
74 VSTPluginUI::package (Gtk::Window& win)
75 {
76         /* Forward configure events to plugin window */
77         win.signal_configure_event().connect (sigc::mem_fun (*this, &VSTPluginUI::configure_handler), false);
78
79         /* This assumes that the window's owner understands the XEmbed protocol */
80         _socket.add_id (get_XID ());
81         
82         return 0;
83 }
84
85 bool
86 VSTPluginUI::configure_handler (GdkEventConfigure* ev)
87 {
88         XEvent event;
89         gint x, y;
90         GdkWindow* w;
91
92         if ((w = _socket.gobj()->plug_window) == 0) {
93                 return false;
94         }
95
96         event.xconfigure.type = ConfigureNotify;
97         event.xconfigure.event = GDK_WINDOW_XWINDOW (w);
98         event.xconfigure.window = GDK_WINDOW_XWINDOW (w);
99
100         /* The ICCCM says that synthetic events should have root relative
101          * coordinates. We still aren't really ICCCM compliant, since
102          * we don't send events when the real toplevel is moved.
103          */
104         gdk_error_trap_push ();
105         gdk_window_get_origin (w, &x, &y);
106         gdk_error_trap_pop ();
107
108         event.xconfigure.x = x;
109         event.xconfigure.y = y;
110         event.xconfigure.width = GTK_WIDGET (_socket.gobj())->allocation.width;
111         event.xconfigure.height = GTK_WIDGET (_socket.gobj())->allocation.height;
112
113         event.xconfigure.border_width = 0;
114         event.xconfigure.above = None;
115         event.xconfigure.override_redirect = False;
116
117         gdk_error_trap_push ();
118         XSendEvent (GDK_WINDOW_XDISPLAY (w), GDK_WINDOW_XWINDOW (w), False, StructureNotifyMask, &event);
119         gdk_error_trap_pop ();
120
121         return false;
122 }
123