1 /* GSequencer - Advanced GTK Sequencer
2 * Copyright (C) 2005-2020 Joël Krähemann
3 *
4 * This file is part of GSequencer.
5 *
6 * GSequencer is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GSequencer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GSequencer. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <ags/X/ags_dssi_browser_callbacks.h>
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <sys/types.h>
26 #include <unistd.h>
27
28 #include <dssi.h>
29
30 #include <ags/i18n.h>
31
32 void
ags_dssi_browser_plugin_filename_callback(GtkComboBoxText * combo_box,AgsDssiBrowser * dssi_browser)33 ags_dssi_browser_plugin_filename_callback(GtkComboBoxText *combo_box,
34 AgsDssiBrowser *dssi_browser)
35 {
36 GtkComboBoxText *filename, *effect;
37
38 AgsDssiManager *dssi_manager;
39 AgsDssiPlugin *dssi_plugin;
40
41 GList *start_list, *list;
42
43 gchar *str;
44
45 GRecMutex *dssi_manager_mutex;
46
47 filename = GTK_COMBO_BOX_TEXT(dssi_browser->filename);
48 effect = GTK_COMBO_BOX_TEXT(dssi_browser->effect);
49
50 gtk_list_store_clear(GTK_LIST_STORE(effect));
51
52 dssi_manager = ags_dssi_manager_get_instance();
53
54 /* get dssi manager mutex */
55 dssi_manager_mutex = AGS_DSSI_MANAGER_GET_OBJ_MUTEX(dssi_manager);
56
57 /* get dssi plugin */
58 g_rec_mutex_lock(dssi_manager_mutex);
59
60 list =
61 start_list = g_list_copy_deep(dssi_manager->dssi_plugin,
62 (GCopyFunc) g_object_ref,
63 NULL);
64
65 g_rec_mutex_unlock(dssi_manager_mutex);
66
67 str = gtk_combo_box_text_get_active_text(filename);
68
69 while((list = ags_base_plugin_find_filename(list, str)) != NULL){
70 gchar *str;
71
72 dssi_plugin = list->data;
73
74 /* set effect */
75 g_object_get(dssi_plugin,
76 "effect", &str,
77 NULL);
78
79 if(str != NULL){
80 gtk_combo_box_text_append_text(effect,
81 str);
82 }
83
84 g_free(str);
85
86 /* iterate */
87 list = list->next;
88 }
89
90 gtk_combo_box_set_active((GtkComboBox *) effect,
91 0);
92
93 g_list_free_full(start_list,
94 g_object_unref);
95 }
96
97 void
ags_dssi_browser_plugin_effect_callback(GtkComboBoxText * combo_box,AgsDssiBrowser * dssi_browser)98 ags_dssi_browser_plugin_effect_callback(GtkComboBoxText *combo_box,
99 AgsDssiBrowser *dssi_browser)
100 {
101 GtkComboBoxText *filename, *effect;
102 GtkGrid *grid;
103
104 AgsDssiPlugin *dssi_plugin;
105
106 GList *child, *start_child;
107
108 gchar *str;
109
110 guint effect_index;
111 guint port_count;
112 guint y;
113 unsigned long i;
114
115 void *plugin_so;
116 DSSI_Descriptor *plugin_descriptor;
117 const LADSPA_PortDescriptor *port_descriptor;
118
119 GRecMutex *base_plugin_mutex;
120
121 /* retrieve filename and effect */
122 filename = GTK_COMBO_BOX_TEXT(dssi_browser->filename);
123 effect = GTK_COMBO_BOX_TEXT(dssi_browser->effect);
124
125 dssi_plugin = ags_dssi_manager_find_dssi_plugin(ags_dssi_manager_get_instance(),
126 gtk_combo_box_text_get_active_text(filename),
127 gtk_combo_box_text_get_active_text(effect));
128
129 g_object_get(dssi_plugin,
130 "plugin-so", &plugin_so,
131 "effect-index", &effect_index,
132 NULL);
133
134 /* update description */
135 if(plugin_so){
136 /* get base plugin mutex */
137 base_plugin_mutex = AGS_BASE_PLUGIN_GET_OBJ_MUTEX(dssi_plugin);
138
139 /* plugin and port descriptor */
140 g_rec_mutex_lock(base_plugin_mutex);
141
142 plugin_descriptor = AGS_DSSI_PLUGIN_DESCRIPTOR(AGS_BASE_PLUGIN(dssi_plugin)->plugin_descriptor);
143
144 port_descriptor = plugin_descriptor->LADSPA_Plugin->PortDescriptors;
145
146 /* update ui - reading plugin file */
147 str = g_strconcat(i18n("Label"),
148 ": ",
149 plugin_descriptor->LADSPA_Plugin->Label,
150 NULL);
151 gtk_label_set_text(dssi_browser->label,
152 str);
153
154 g_free(str);
155
156 str = g_strconcat(i18n("Maker"),
157 ": ",
158 plugin_descriptor->LADSPA_Plugin->Label,
159 NULL);
160 gtk_label_set_text(dssi_browser->maker,
161 str);
162
163 g_free(str);
164
165 str = g_strconcat(i18n("Copyright"),
166 ": ",
167 plugin_descriptor->LADSPA_Plugin->Label,
168 NULL);
169 gtk_label_set_text(dssi_browser->copyright,
170 str);
171
172 g_free(str);
173
174 /* update ui - port information */
175 port_count = plugin_descriptor->LADSPA_Plugin->PortCount;
176
177 grid = dssi_browser->port_grid;
178
179 child =
180 start_child = gtk_container_get_children(GTK_CONTAINER(grid));
181
182 while(child != NULL){
183 gtk_widget_destroy(GTK_WIDGET(child->data));
184
185 child = child->next;
186 }
187
188 g_list_free(start_child);
189
190 for(i = 0, y = 0; i < port_count; i++){
191 GtkLabel *label;
192
193 if(!(LADSPA_IS_PORT_CONTROL(port_descriptor[i]) &&
194 (LADSPA_IS_PORT_INPUT(port_descriptor[i]) ||
195 LADSPA_IS_PORT_OUTPUT(port_descriptor[i])))){
196 continue;
197 }
198
199 str = g_strdup(plugin_descriptor->LADSPA_Plugin->PortNames[i]);
200
201 label = (GtkLabel *) g_object_new(GTK_TYPE_LABEL,
202 "xalign", 0.0,
203 "label", str,
204 NULL);
205 gtk_grid_attach(grid,
206 (GtkWidget *) label,
207 0, y,
208 1, 1);
209
210 gtk_grid_attach(grid,
211 (GtkWidget *) ags_dssi_browser_combo_box_controls_new(),
212 1, y,
213 1, 1);
214
215 y++;
216 }
217
218 g_rec_mutex_unlock(base_plugin_mutex);
219
220 gtk_widget_show_all((GtkWidget *) grid);
221 }else{
222 /* update ui - empty */
223 str = g_strdup_printf("%s: ",
224 i18n("Label"));
225 gtk_label_set_text(dssi_browser->label,
226 str);
227
228 g_free(str);
229
230 str = g_strdup_printf("%s: ",
231 i18n("Maker"));
232 gtk_label_set_text(dssi_browser->maker,
233 str);
234
235 g_free(str);
236
237 str = g_strdup_printf("%s: ",
238 i18n("Copyright"));
239 gtk_label_set_text(dssi_browser->copyright,
240 str);
241
242 g_free(str);
243
244 /* update ui - no ports */
245 grid = dssi_browser->port_grid;
246
247 child =
248 start_child = gtk_container_get_children(GTK_CONTAINER(grid));
249
250 while(child != NULL){
251 gtk_widget_destroy(GTK_WIDGET(child->data));
252
253 child = child->next;
254 }
255
256 g_list_free(start_child);
257 }
258 }
259