diff options
author | David Robillard <d@drobilla.net> | 2011-06-01 19:14:25 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-06-01 19:14:25 +0000 |
commit | b4241912379b321a1a2ec0d192faff12f8db2101 (patch) | |
tree | 9f9bb51ca2aefbcf0f3499f9388a5048773c7d62 | |
parent | 02fe4df201838c381d4106ec92849cbb5b959ccb (diff) | |
download | suil-b4241912379b321a1a2ec0d192faff12f8db2101.tar.gz suil-b4241912379b321a1a2ec0d192faff12f8db2101.tar.bz2 suil-b4241912379b321a1a2ec0d192faff12f8db2101.zip |
Fix GtkBuilder using (and likely other) Gtk UIs in Qt4 hosts that do not link to Gtk (fix ticket #696).
git-svn-id: http://svn.drobilla.net/lad/trunk/suil@3345 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/gtk2_in_qt4.cpp | 20 | ||||
-rw-r--r-- | src/host.c | 4 | ||||
-rw-r--r-- | src/instance.c | 2 | ||||
-rw-r--r-- | src/qt4_in_gtk2.cpp | 3 | ||||
-rw-r--r-- | src/suil_internal.h | 16 | ||||
-rw-r--r-- | wscript | 14 |
6 files changed, 46 insertions, 13 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; } @@ -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); @@ -7,7 +7,7 @@ from waflib.extras import autowaf as autowaf import waflib.Logs as Logs, waflib.Options as Options # Version of this package (even if built as a child) -SUIL_VERSION = '0.4.2' +SUIL_VERSION = '0.4.3' SUIL_MAJOR_VERSION = '0' # Library version (UNIX style major, minor, micro) @@ -27,6 +27,9 @@ out = 'build' def options(opt): autowaf.set_options(opt) + opt.add_option('--gtk2-lib-name', type='string', dest='gtk2_lib_name', + default="libgtk-x11-2.0.so", + help="Gtk2 library name [Default: libgtk-x11-2.0.so]") def configure(conf): conf.line_just = 56 @@ -54,13 +57,18 @@ def configure(conf): conf.env['LIBDIR'] + '/suil-' + SUIL_MAJOR_VERSION) autowaf.define(conf, 'SUIL_DIR_SEP', '/') autowaf.define(conf, 'SUIL_MODULE_EXT', '.so') + autowaf.define(conf, 'SUIL_GTK2_LIB_NAME', Options.options.gtk2_lib_name); conf.env['LIB_SUIL'] = ['suil-%s' % SUIL_MAJOR_VERSION] conf.write_config_header('suil-config.h', remove=False) - autowaf.display_msg(conf, "Gtk2 Support", conf.is_defined('HAVE_GTK2')) - autowaf.display_msg(conf, "Qt4 Support", conf.is_defined('HAVE_QT4')) + autowaf.display_msg(conf, "Gtk2 Support", + conf.is_defined('HAVE_GTK2')) + autowaf.display_msg(conf, "Gtk2 Library Name", + conf.env['SUIL_GTK2_LIB_NAME']) + autowaf.display_msg(conf, "Qt4 Support", + conf.is_defined('HAVE_QT4')) print('') def build(bld): |