diff options
-rw-r--r-- | src/jalv_gtkmm2.cpp | 80 | ||||
-rw-r--r-- | wscript | 14 |
2 files changed, 94 insertions, 0 deletions
diff --git a/src/jalv_gtkmm2.cpp b/src/jalv_gtkmm2.cpp new file mode 100644 index 0000000..811729a --- /dev/null +++ b/src/jalv_gtkmm2.cpp @@ -0,0 +1,80 @@ +/* + Copyright 2007-2012 David Robillard <http://drobilla.net> + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include <gtkmm.h> + +#include "jalv_internal.h" + +Gtk::Main* jalv_gtk_main = NULL; + +int +jalv_init(int* argc, char*** argv, JalvOptions* opts) +{ + jalv_gtk_main = new Gtk::Main(*argc, *argv); + return 0; +} + +LilvNode* +jalv_native_ui_type(Jalv* jalv) +{ + return lilv_new_uri(jalv->world, + "http://lv2plug.in/ns/extensions/ui#GtkUI"); +} + +int +jalv_ui_resize(Jalv* jalv, int width, int height) +{ + if (jalv->ui_instance) { + GtkWidget* widget = GTK_WIDGET( + suil_instance_get_widget(jalv->ui_instance)); + if (widget) { + gtk_widget_set_size_request(GTK_WIDGET(widget), width, height); + } + } + return 0; +} + +int +jalv_open_ui(Jalv* jalv, + SuilInstance* instance) +{ + Gtk::Window* window = new Gtk::Window(); + + if (instance) { + GtkWidget* widget = (GtkWidget*)suil_instance_get_widget(instance); + Gtk::Widget* widgetmm = Glib::wrap(widget); + window->add(*Gtk::manage(widgetmm)); + widgetmm->show_all(); + + g_timeout_add(1000 / JALV_UI_UPDATE_HZ, + (GSourceFunc)jalv_emit_ui_events, jalv); + } else { + Gtk::Button* button = Gtk::manage(new Gtk::Button("Close")); + window->add(*Gtk::manage(button)); + } + + // TODO: Check UI properties for resizable + window->set_resizable(false); + window->show_all(); + + Gtk::Main::run(*window); + + delete window; + delete jalv_gtk_main; + zix_sem_post(jalv->done); + + return 0; +} @@ -45,6 +45,8 @@ def configure(conf): atleast_version='0.120.0', mandatory=True) autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK2', atleast_version='2.18.0', mandatory=False) + autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM2', + atleast_version='2.20.0', mandatory=False) autowaf.check_pkg(conf, 'QtGui', uselib_store='QT4', atleast_version='4.0.0', mandatory=False) @@ -72,6 +74,8 @@ def configure(conf): conf.is_defined('HAVE_LV2_STATE')) autowaf.display_msg(conf, "Gtk 2.0 support", conf.is_defined('HAVE_GTK2')) + autowaf.display_msg(conf, "Gtkmm 2.0 support", + conf.is_defined('HAVE_GTKMM2')) autowaf.display_msg(conf, "Qt 4.0 support", conf.is_defined('HAVE_QT4')) print('') @@ -100,6 +104,16 @@ def build(bld): install_path = '${BINDIR}') autowaf.use_lib(bld, obj, libs + ' GTK2') + # Gtkmm version + if bld.is_defined('HAVE_GTKMM2'): + obj = bld(features = 'c cxx cxxprogram', + source = source + ' src/jalv_gtkmm2.cpp', + target = 'jalv.gtkmm', + includes = ['.', 'src'], + lib = ['pthread'], + install_path = '${BINDIR}') + autowaf.use_lib(bld, obj, libs + ' GTKMM2') + # Qt version if bld.is_defined('HAVE_QT4'): obj = bld(features = 'c cxx cxxprogram', |