1 /***************************************************************************
2  *   Copyright (C) 2011 by Pere Ràfols Soler                               *
3  *   sapista2@gmail.com                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 
21 /***************************************************************************
22 This file contains some definitions of the BassUp plugin UI
23 This plugin is inside the Sapista Plugins Bundle
24 ****************************************************************************/
25 
26 //LV2 UI headers
27 #include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
28 #include <gtkmm/main.h>
29 #include "widgets/bassupwindow.h"
30 
31 //Testing Headers TODO: comment define TESTING_EQ10Q for the final relase
32 //#define TESTING_EQ10Q
33 #ifdef TESTING_EQ10Q
34 #include <iostream>
35 using namespace std;
36 #endif
37 
38 #define BASSUP_GUI_URI "http://eq10q.sourceforge.net/bassup/gui"
39 
40 
instantiateBassUp_gui(const LV2UI_Descriptor * descriptor,const char * plugin_uri,const char * bundle_path,LV2UI_Write_Function write_function,LV2UI_Controller controller,LV2UI_Widget * widget,const LV2_Feature * const * features)41 static LV2UI_Handle instantiateBassUp_gui(const LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
42 {
43   #ifdef TESTING_EQ10Q
44   cout<<"instantiateEq10q_gui Entring... ";
45   #endif
46 
47   Gtk::Main::init_gtkmm_internals();
48   BassUpMainWindow* gui_data = new BassUpMainWindow(plugin_uri, std::string(bundle_path));
49   gui_data->controller = controller;
50   gui_data->write_function = write_function;
51   *widget = gui_data->gobj();
52 
53   #ifdef TESTING_EQ10Q
54   cout<<" Done"<<endl;
55   #endif
56 
57   return (LV2UI_Handle)gui_data;
58 }
59 
60 
cleanupBassUp_gui(LV2UI_Handle instance)61 static void cleanupBassUp_gui(LV2UI_Handle instance)
62 {
63   #ifdef TESTING_EQ10Q
64   cout<<"cleanupEq10q_gui Entring... ";
65   #endif
66 
67   ///delete static_cast<BassUpMainWindow*>(instance);
68   BassUpMainWindow *gui = (BassUpMainWindow *)instance;
69   delete gui;
70 
71   #ifdef TESTING_EQ10Q
72   cout<<" Done"<<endl;
73   #endif
74 }
75 
portEventBassUp_gui(LV2UI_Handle ui,uint32_t port_index,uint32_t buffer_size,uint32_t format,const void * buffer)76 static void portEventBassUp_gui(LV2UI_Handle ui, uint32_t port_index, uint32_t buffer_size, uint32_t format, const void *buffer)
77 {
78   #ifdef TESTING_EQ10Q
79   cout<<"portEventEq10q_gui Entring... "<<"Port Index = "<<port_index;
80   #endif
81 
82   BassUpMainWindow *gui = (BassUpMainWindow *)ui;
83   gui->gui_port_event(ui, port_index, buffer_size, format, buffer);
84 
85   #ifdef TESTING_EQ10Q
86   cout<<" Done"<<endl;
87   #endif
88 }
89 
90 static const LV2UI_Descriptor bassup_guiDescriptor = {
91   BASSUP_GUI_URI,
92   instantiateBassUp_gui,
93   cleanupBassUp_gui,
94   portEventBassUp_gui,
95   NULL
96 };
97 
98 LV2_SYMBOL_EXPORT
lv2ui_descriptor(uint32_t index)99 const LV2UI_Descriptor *lv2ui_descriptor(uint32_t index)
100 {
101   #ifdef TESTING_EQ10Q
102   cout<<"lv2ui_descriptor Entring... ";
103   #endif
104 
105     switch (index) {
106             case 0:
107                     #ifdef TESTING_EQ10Q
108                     cout<<" Done with OK result (return LV2UI_Descriptor)"<<endl;
109                     #endif
110                     return &bassup_guiDescriptor;
111             default:
112                     #ifdef TESTING_EQ10Q
113                     cout<<" Done with NOK result (return NULL)"<<endl;
114                     #endif
115                     return NULL;
116     }
117 
118 
119 }