summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-01 20:08:05 +0000
committerDavid Robillard <d@drobilla.net>2007-07-01 20:08:05 +0000
commit87a7c71254f292939410b7fe376c80f4d8cd815e (patch)
treef501dd98b09b4d65ec518affc763faa3f958bd4c
parente67a923c73c26dfd335cfb325511c831996952ab (diff)
downloadlilv-87a7c71254f292939410b7fe376c80f4d8cd815e.tar.gz
lilv-87a7c71254f292939410b7fe376c80f4d8cd815e.tar.bz2
lilv-87a7c71254f292939410b7fe376c80f4d8cd815e.zip
Removed redundant GUI loading stub (I'm an idiot).
Cleaned up messy GUI code. Added _gtk2 to gtk2 specific GUI function names (is a nicer more abstract way than this possible?). Fixed instantiation bugs caused by last commit's bundle URI stuff. git-svn-id: http://svn.drobilla.net/lad/slv2@554 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--AUTHORS5
-rw-r--r--configure.ac2
-rw-r--r--slv2/plugin.h14
-rw-r--r--slv2/pluginguiinstance.h25
-rw-r--r--src/pluginguiinstance.c63
-rw-r--r--src/plugininstance.c4
-rw-r--r--src/slv2_internal.h10
7 files changed, 56 insertions, 67 deletions
diff --git a/AUTHORS b/AUTHORS
index 38a0b65..c6237c6 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,5 @@
-Dave Robillard <dave@drobilla.net>
+Author:
+ Dave Robillard <dave@drobilla.net>
+GTK2 GUI support:
+ Lars Luthman <lars.luthman@gmail.com>
diff --git a/configure.ac b/configure.ac
index 6b96dea..7285819 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,7 +54,7 @@ AC_ARG_ENABLE(strict,
[AS_HELP_STRING(--enable-strict, [Enable strict compiler warnings and errors (false)])],
[strict="$enableval"])
if test "$strict" = "yes"; then
- CFLAGS="$CFLAGS -std=c99 -pedantic -Wall -Wextra -Wconversion -Winit-self"
+ CFLAGS="$CFLAGS -std=c99 -pedantic -Wall -Wextra -Winit-self"
CXXFLAGS="$CFLAGS -ansi -pedantic -Wall -Wextra -Wconversion -Winit-self"
fi
diff --git a/slv2/plugin.h b/slv2/plugin.h
index f77ca16..18e0d01 100644
--- a/slv2/plugin.h
+++ b/slv2/plugin.h
@@ -371,20 +371,6 @@ slv2_plugin_get_gui_library_uri(SLV2Plugin plugin,
SLV2Value gui);
-/** Load and instantiate a plugin GUI.
- *
- * The type returned depends on the type of the GUI. For SLV2_GTK2_GUI, the
- * return value must be cast to LV2UI_Handle.
- *
- * NULL returned on error.
- *
- * Time = Query + O(# of GUIs in GUI shared library)
- */
-void*
-slv2_plugin_load_gui(SLV2Plugin plugin,
- SLV2Value gui);
-
-
/** @} */
#ifdef __cplusplus
diff --git a/slv2/pluginguiinstance.h b/slv2/pluginguiinstance.h
index 82628a7..7801256 100644
--- a/slv2/pluginguiinstance.h
+++ b/slv2/pluginguiinstance.h
@@ -1,5 +1,6 @@
/* SLV2
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ * Author: Lars Luthman
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -38,7 +39,7 @@ extern "C" {
*/
-typedef struct _GUIInstanceImpl* SLV2GUIInstanceImpl;
+typedef struct _SLV2GUIInstanceImpl* SLV2GUIInstanceImpl;
struct _GtkWidget;
@@ -49,8 +50,8 @@ struct _GtkWidget;
* All details are in hidden in the pimpl member to avoid making the
* implementation a part of the ABI.
*/
-typedef struct _GUIInstance {
- SLV2GUIInstanceImpl pimpl; ///< Private implementation
+typedef struct _SLV2GUIInstance {
+ SLV2GUIInstanceImpl pimpl; ///< Private implementation
}* SLV2GUIInstance;
@@ -71,11 +72,11 @@ typedef struct _GUIInstance {
* \return NULL if instantiation failed.
*/
SLV2GUIInstance
-slv2_plugin_gui_instantiate(SLV2Plugin plugin,
- SLV2Value gui,
- LV2UI_Set_Control_Function control_function,
- LV2UI_Controller controller,
- const LV2_Host_Feature** host_features);
+slv2_plugin_gtk2_gui_instantiate(SLV2Plugin plugin,
+ SLV2Value gui,
+ LV2UI_Set_Control_Function control_function,
+ LV2UI_Controller controller,
+ const LV2_Host_Feature** host_features);
/** Free a plugin GUI instance.
@@ -83,13 +84,13 @@ slv2_plugin_gui_instantiate(SLV2Plugin plugin,
* \a instance is invalid after this call.
*/
void
-slv2_gui_instance_free(SLV2GUIInstance instance);
+slv2_gtk2_gui_instance_free(SLV2GUIInstance instance);
/** Get the GTK+ 2.0 widget for the GUI instance.
*/
struct _GtkWidget*
-slv2_gui_instance_get_widget(SLV2GUIInstance instance);
+slv2_gtk2_gui_instance_get_widget(SLV2GUIInstance instance);
/** Get the LV2UI_Descriptor of the plugin GUI instance.
@@ -100,7 +101,7 @@ slv2_gui_instance_get_widget(SLV2GUIInstance instance);
* The returned descriptor is shared and must not be deleted.
*/
const LV2UI_Descriptor*
-slv2_gui_instance_get_descriptor(SLV2GUIInstance instance);
+slv2_gtk2_gui_instance_get_descriptor(SLV2GUIInstance instance);
/** Get the LV2UI_Handle of the plugin GUI instance.
@@ -111,7 +112,7 @@ slv2_gui_instance_get_descriptor(SLV2GUIInstance instance);
* The returned handle is shared and must not be deleted.
*/
LV2_Handle
-slv2_gui_instance_get_handle(SLV2GUIInstance instance);
+slv2_gtk2_gui_instance_get_handle(SLV2GUIInstance instance);
/** @} */
diff --git a/src/pluginguiinstance.c b/src/pluginguiinstance.c
index ea4f9a7..95f0331 100644
--- a/src/pluginguiinstance.c
+++ b/src/pluginguiinstance.c
@@ -1,6 +1,7 @@
/* SLV2
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
+ * Author: Lars Luthman
+ *
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
@@ -31,13 +32,18 @@
SLV2GUIInstance
-slv2_plugin_gui_instantiate(SLV2Plugin plugin,
- SLV2Value gui,
- LV2UI_Set_Control_Function control_function,
- LV2UI_Controller controller,
- const LV2_Host_Feature** host_features)
+slv2_plugin_gtk2_gui_instantiate(SLV2Plugin plugin,
+ SLV2Value gui,
+ LV2UI_Set_Control_Function control_function,
+ LV2UI_Controller controller,
+ const LV2_Host_Feature** host_features)
{
- struct _GUIInstance* result = NULL;
+ assert(gui->type == SLV2_VALUE_GUI);
+
+ if (gui->val.gui_type_val != SLV2_GTK2_GUI)
+ return NULL;
+
+ struct _SLV2GUIInstance* result = NULL;
bool local_host_features = (host_features == NULL);
if (local_host_features) {
@@ -57,9 +63,9 @@ slv2_plugin_gui_instantiate(SLV2Plugin plugin,
fprintf(stderr, "Unable to open GUI library %s (%s)\n", lib_path, dlerror());
return NULL;
}
-
+
LV2UI_DescriptorFunction df = dlsym(lib, "lv2ui_descriptor");
-
+
if (!df) {
fprintf(stderr, "Could not find symbol 'lv2ui_descriptor', "
"%s is not a LV2 plugin GUI.\n", lib_path);
@@ -68,11 +74,8 @@ slv2_plugin_gui_instantiate(SLV2Plugin plugin,
} else {
// Search for plugin by URI
- // FIXME: Kluge to get bundle path (containing directory of binary)
- char* bundle_path = strdup(plugin->binary_uri);
- char* const bundle_path_end = strrchr(bundle_path, '/');
- if (bundle_path_end)
- *(bundle_path_end+1) = '\0';
+ // FIXME: Bundle in plugin GUI only, boo
+ const char* bundle_path = slv2_uri_to_path(slv2_plugin_get_bundle_uri(plugin));
printf("GUI bundle path: %s\n", bundle_path);
for (uint32_t i=0; 1; ++i) {
@@ -92,23 +95,21 @@ slv2_plugin_gui_instantiate(SLV2Plugin plugin,
assert(ld->instantiate);
// Create SLV2GUIInstance to return
- result = malloc(sizeof(struct _GUIInstance));
- struct _GUIInstanceImpl* impl = malloc(sizeof(struct _GUIInstanceImpl));
+ result = malloc(sizeof(struct _SLV2GUIInstance));
+ struct _SLV2GUIInstanceImpl* impl = malloc(sizeof(struct _SLV2GUIInstanceImpl));
impl->lv2ui_descriptor = ld;
impl->lv2ui_handle = ld->instantiate(ld,
- slv2_plugin_get_uri(plugin),
- (char*)bundle_path,
- control_function,
- controller,
- (struct _GtkWidget**)&impl->widget,
- host_features);
+ slv2_plugin_get_uri(plugin),
+ (char*)bundle_path,
+ control_function,
+ controller,
+ (struct _GtkWidget**)&impl->widget,
+ host_features);
impl->lib_handle = lib;
result->pimpl = impl;
break;
}
}
-
- free(bundle_path);
}
assert(result);
@@ -124,8 +125,8 @@ slv2_plugin_gui_instantiate(SLV2Plugin plugin,
// Failed to create a widget, but still got a handle - this means that
// the plugin is buggy
if (result->pimpl->widget == NULL) {
- slv2_gui_instance_free(result);
- return NULL;
+ slv2_gtk2_gui_instance_free(result);
+ return NULL;
}
if (local_host_features)
@@ -136,9 +137,9 @@ slv2_plugin_gui_instantiate(SLV2Plugin plugin,
void
-slv2_gui_instance_free(SLV2GUIInstance instance)
+slv2_gtk2_gui_instance_free(SLV2GUIInstance instance)
{
- struct _GUIInstance* i = (struct _GUIInstance*)instance;
+ struct _SLV2GUIInstance* i = (struct _SLV2GUIInstance*)instance;
i->pimpl->lv2ui_descriptor->cleanup(i->pimpl->lv2ui_handle);
i->pimpl->lv2ui_descriptor = NULL;
dlclose(i->pimpl->lib_handle);
@@ -151,18 +152,18 @@ slv2_gui_instance_free(SLV2GUIInstance instance)
struct _GtkWidget*
slv2_gui_instance_get_widget(SLV2GUIInstance instance) {
- return instance->pimpl->widget;
+ return instance->pimpl->widget;
}
const LV2UI_Descriptor*
slv2_gui_instance_get_descriptor(SLV2GUIInstance instance) {
- return instance->pimpl->lv2ui_descriptor;
+ return instance->pimpl->lv2ui_descriptor;
}
LV2_Handle
slv2_gui_instance_get_handle(SLV2GUIInstance instance) {
- return instance->pimpl->lv2ui_handle;
+ return instance->pimpl->lv2ui_handle;
}
diff --git a/src/plugininstance.c b/src/plugininstance.c
index 90af196..be2252c 100644
--- a/src/plugininstance.c
+++ b/src/plugininstance.c
@@ -67,7 +67,7 @@ slv2_plugin_instantiate(SLV2Plugin plugin,
// Search for plugin by URI
// FIXME: Kluge to get bundle path (containing directory of binary)
- char* bundle_path = slv2_uri_to_path(strdup(slv2_plugin_get_bundle_uri(plugin)));
+ const char* bundle_path = slv2_uri_to_path(slv2_plugin_get_bundle_uri(plugin));
printf("Bundle path: %s\n", bundle_path);
for (uint32_t i=0; 1; ++i) {
@@ -97,8 +97,6 @@ slv2_plugin_instantiate(SLV2Plugin plugin,
break;
}
}
-
- free(bundle_path);
}
assert(result);
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index ca1e002..2694b5d 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -99,11 +99,11 @@ struct _InstanceImpl {
/* ********* GUI Instance ********* */
-struct _GUIInstanceImpl {
- void* lib_handle;
- const LV2UI_Descriptor* lv2ui_descriptor;
- LV2UI_Handle lv2ui_handle;
- void* widget;
+struct _SLV2GUIInstanceImpl {
+ void* lib_handle;
+ const LV2UI_Descriptor* lv2ui_descriptor;
+ LV2UI_Handle lv2ui_handle;
+ void* widget;
};