summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gtk2_in_qt4.cpp20
-rw-r--r--src/host.c4
-rw-r--r--src/instance.c2
-rw-r--r--src/qt4_in_gtk2.cpp3
-rw-r--r--src/suil_internal.h16
5 files changed, 35 insertions, 10 deletions
diff --git a/src/gtk2_in_qt4.cpp b/src/gtk2_in_qt4.cpp
index 91fa3b1..585d1d5 100644
--- a/src/gtk2_in_qt4.cpp
+++ b/src/gtk2_in_qt4.cpp
@@ -21,16 +21,32 @@
#include <gdk/gdkx.h>
#include "suil_internal.h"
+#include "suil-config.h"
extern "C" {
SUIL_API
int
-suil_wrap_init(const char* host_type_uri,
+suil_wrap_init(SuilHost* host,
+ const char* host_type_uri,
const char* ui_type_uri,
const LV2_Feature* const* features)
{
- gtk_init(0, NULL);
+ /* We have to open libgtk here, so Gtk type symbols are present and will be
+ found by the introspection stuff. This is required at least to make
+ GtkBuilder use in UIs work, otherwise they will cause "Invalid object
+ type" errors.
+ */
+ if (!host->gtk_lib) {
+ dlerror();
+ host->gtk_lib = dlopen(SUIL_GTK2_LIB_NAME, RTLD_LAZY|RTLD_GLOBAL);
+ if (!host->gtk_lib) {
+ fprintf(stderr, "Failed to open %s (%s)\n",
+ SUIL_GTK2_LIB_NAME, dlerror());
+ }
+ return 1;
+ }
+
return 0;
}
diff --git a/src/host.c b/src/host.c
index 48b0b6a..c57b1c6 100644
--- a/src/host.c
+++ b/src/host.c
@@ -28,6 +28,7 @@ suil_host_new(SuilPortWriteFunc write_func,
host->index_func = index_func;
host->subscribe_func = subscribe_func;
host->unsubscribe_func = unsubscribe_func;
+ host->gtk_lib = NULL;
return host;
}
@@ -35,5 +36,8 @@ SUIL_API
void
suil_host_free(SuilHost* host)
{
+ if (host->gtk_lib) {
+ dlclose(host->gtk_lib);
+ }
free(host);
}
diff --git a/src/instance.c b/src/instance.c
index d619d74..e1f8e8e 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -170,7 +170,7 @@ suil_instance_new(SuilHost* host,
SuilModule module = get_wrap_module(container_type_uri, ui_type_uri);
if (module) {
- module->init(container_type_uri, ui_type_uri, features);
+ module->init(host, container_type_uri, ui_type_uri, features);
}
// Instantiate UI
diff --git a/src/qt4_in_gtk2.cpp b/src/qt4_in_gtk2.cpp
index e056b65..191215e 100644
--- a/src/qt4_in_gtk2.cpp
+++ b/src/qt4_in_gtk2.cpp
@@ -29,7 +29,8 @@ static QApplication application(argc, NULL, true);
SUIL_API
int
-suil_wrap_init(const char* host_type_uri,
+suil_wrap_init(SuilHost* host,
+ const char* host_type_uri,
const char* ui_type_uri,
const LV2_Feature* const* features)
{
diff --git a/src/suil_internal.h b/src/suil_internal.h
index 53ee0a8..5987f1c 100644
--- a/src/suil_internal.h
+++ b/src/suil_internal.h
@@ -42,6 +42,7 @@ struct SuilHostImpl {
SuilPortIndexFunc index_func;
SuilPortSubscribeFunc subscribe_func;
SuilPortUnsubscribeFunc unsubscribe_func;
+ void* gtk_lib;
};
struct SuilInstanceImpl {
@@ -52,12 +53,15 @@ struct SuilInstanceImpl {
SuilWidget host_widget;
};
-/** Type of a module's suil_wrap_init function.
- * This initialisation function must be called before instantiating any
- * UI that will need to be wrapped by this wrapper (e.g. it will perform any
- * initialisation required to create a widget for the given toolkit).
- */
-typedef int (*SuilWrapInitFunc)(const char* host_type_uri,
+/**
+ Type of a module's suil_wrap_init function.
+
+ This initialisation function must be called before instantiating any UI that
+ will need to be wrapped by this wrapper (e.g. it will perform any
+ initialisation required to create a widget for the given toolkit).
+*/
+typedef int (*SuilWrapInitFunc)(SuilHost* host,
+ const char* host_type_uri,
const char* ui_type_uri,
const LV2_Feature* const* features);