1 /* GSequencer - Advanced GTK Sequencer
2 * Copyright (C) 2005-2021 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_plugin_preferences.h>
21 #include <ags/X/ags_plugin_preferences_callbacks.h>
22
23 #include <ags/X/ags_window.h>
24 #include <ags/X/ags_preferences.h>
25
26 void ags_plugin_preferences_class_init(AgsPluginPreferencesClass *plugin_preferences);
27 void ags_plugin_preferences_connectable_interface_init(AgsConnectableInterface *connectable);
28 void ags_plugin_preferences_init(AgsPluginPreferences *plugin_preferences);
29
30 void ags_plugin_preferences_connect(AgsConnectable *connectable);
31 void ags_plugin_preferences_disconnect(AgsConnectable *connectable);
32
33 void ags_plugin_preferences_reset(AgsPluginPreferences *plugin_preferences);
34 void* ags_plugin_preferences_refresh(void *ptr);
35
36 /**
37 * SECTION:ags_plugin_preferences
38 * @short_description: A composite widget to do plugin related preferences
39 * @title: AgsPluginPreferences
40 * @section_id:
41 * @include: ags/X/ags_plugin_preferences.h
42 *
43 * #AgsPluginPreferences enables you to make plugin related preferences.
44 */
45
46 static gpointer ags_plugin_preferences_parent_class = NULL;
47
48 GType
ags_plugin_preferences_get_type(void)49 ags_plugin_preferences_get_type(void)
50 {
51 static volatile gsize g_define_type_id__volatile = 0;
52
53 if(g_once_init_enter (&g_define_type_id__volatile)){
54 GType ags_type_plugin_preferences = 0;
55
56 static const GTypeInfo ags_plugin_preferences_info = {
57 sizeof (AgsPluginPreferencesClass),
58 NULL, /* base_init */
59 NULL, /* base_finalize */
60 (GClassInitFunc) ags_plugin_preferences_class_init,
61 NULL, /* class_finalize */
62 NULL, /* class_data */
63 sizeof (AgsPluginPreferences),
64 0, /* n_preallocs */
65 (GInstanceInitFunc) ags_plugin_preferences_init,
66 };
67
68 static const GInterfaceInfo ags_connectable_interface_info = {
69 (GInterfaceInitFunc) ags_plugin_preferences_connectable_interface_init,
70 NULL, /* interface_finalize */
71 NULL, /* interface_data */
72 };
73
74 ags_type_plugin_preferences = g_type_register_static(GTK_TYPE_BOX,
75 "AgsPluginPreferences", &ags_plugin_preferences_info,
76 0);
77
78 g_type_add_interface_static(ags_type_plugin_preferences,
79 AGS_TYPE_CONNECTABLE,
80 &ags_connectable_interface_info);
81
82 g_once_init_leave(&g_define_type_id__volatile, ags_type_plugin_preferences);
83 }
84
85 return g_define_type_id__volatile;
86 }
87
88 void
ags_plugin_preferences_class_init(AgsPluginPreferencesClass * plugin_preferences)89 ags_plugin_preferences_class_init(AgsPluginPreferencesClass *plugin_preferences)
90 {
91 ags_plugin_preferences_parent_class = g_type_class_peek_parent(plugin_preferences);
92 }
93
94 void
ags_plugin_preferences_connectable_interface_init(AgsConnectableInterface * connectable)95 ags_plugin_preferences_connectable_interface_init(AgsConnectableInterface *connectable)
96 {
97 connectable->is_ready = NULL;
98 connectable->is_connected = NULL;
99 connectable->connect = ags_plugin_preferences_connect;
100 connectable->disconnect = ags_plugin_preferences_disconnect;
101 }
102
103 void
ags_plugin_preferences_init(AgsPluginPreferences * plugin_preferences)104 ags_plugin_preferences_init(AgsPluginPreferences *plugin_preferences)
105 {
106 gtk_orientable_set_orientation(GTK_ORIENTABLE(plugin_preferences),
107 GTK_ORIENTATION_VERTICAL);
108
109 //TODO:JK: implement me
110 }
111
112 void
ags_plugin_preferences_connect(AgsConnectable * connectable)113 ags_plugin_preferences_connect(AgsConnectable *connectable)
114 {
115 /* empty */
116 }
117
118 void
ags_plugin_preferences_disconnect(AgsConnectable * connectable)119 ags_plugin_preferences_disconnect(AgsConnectable *connectable)
120 {
121 /* empty */
122 }
123
124 AgsLadspaPluginPreferences*
ags_ladspa_plugin_preferences_alloc(gchar * ladspa_path)125 ags_ladspa_plugin_preferences_alloc(gchar *ladspa_path)
126 {
127 AgsLadspaPluginPreferences *ladspa_plugin_preferences;
128 GtkListStore *list_store;
129 GtkTreePath *path;
130 GtkTreeIter iter;
131 gchar **filenames, **filenames_start;
132
133 static const gchar *default_ladspa_path = "/usr/lib/ladspa";
134
135 ladspa_plugin_preferences = (AgsLadspaPluginPreferences *) malloc(sizeof(AgsLadspaPluginPreferences));
136
137 ladspa_plugin_preferences->ladspa_path = (GtkEntry *) gtk_entry_new();
138
139 if(ladspa_path == NULL){
140 gtk_entry_set_text(ladspa_plugin_preferences->ladspa_path,
141 default_ladspa_path);
142 }else{
143 gtk_entry_set_text(ladspa_plugin_preferences->ladspa_path,
144 ladspa_path);
145 }
146
147 ladspa_plugin_preferences->plugin_file = (GtkCellView *) gtk_cell_view_new();
148
149 list_store = gtk_list_store_new(1,
150 G_TYPE_STRING);
151 filenames =
152 filenames_start = ags_ladspa_manager_get_filenames(ags_ladspa_manager_get_instance());
153
154 while(*filenames != NULL){
155 // Add a new row to the model
156 gtk_list_store_append (list_store, &iter);
157 gtk_list_store_set(list_store, &iter,
158 0, *filenames,
159 -1);
160
161 filenames++;
162 }
163
164 free(filenames_start);
165 gtk_cell_view_set_model(ladspa_plugin_preferences->plugin_file,
166 GTK_TREE_MODEL(list_store));
167
168 return(ladspa_plugin_preferences);
169 }
170
171 /**
172 * ags_plugin_preferences_new:
173 *
174 * Create a new instance of #AgsPluginPreferences
175 *
176 * Returns: the new #AgsPluginPreferences
177 *
178 * Since: 3.0.0
179 */
180 AgsPluginPreferences*
ags_plugin_preferences_new()181 ags_plugin_preferences_new()
182 {
183 AgsPluginPreferences *plugin_preferences;
184
185 plugin_preferences = (AgsPluginPreferences *) g_object_new(AGS_TYPE_PLUGIN_PREFERENCES,
186 NULL);
187
188 return(plugin_preferences);
189 }
190