aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--src/jalv_gtk.c (renamed from src/jalv_gtk2.c)53
-rw-r--r--wscript18
3 files changed, 64 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 76c7dde..7fbb883 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ jalv (9999) unstable;
* Tolerate loading presets with port values that aren't xsd:decimal
* Notify plugins of Jack transport changes by sending events (an atom:Blank
with properties from the LV2 time extension)
+ * Add Gtk3 UI
-- David Robillard <d@drobilla.net>
diff --git a/src/jalv_gtk2.c b/src/jalv_gtk.c
index 9ff2013..f385efa 100644
--- a/src/jalv_gtk2.c
+++ b/src/jalv_gtk.c
@@ -22,6 +22,40 @@
#include "jalv_internal.h"
+static GtkWidget*
+new_box(gboolean horizontal, gint spacing)
+{
+ #if GTK_MAJOR_VERSION == 3
+ return gtk_box_new(
+ horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
+ spacing);
+ #else
+ return (horizontal
+ ? gtk_hbox_new(FALSE, spacing)
+ : gtk_vbox_new(FALSE, spacing));
+ #endif
+}
+
+static GtkWidget*
+new_hscale(gdouble min, gdouble max, gdouble step)
+{
+ #if GTK_MAJOR_VERSION == 3
+ return gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, min, max, step);
+ #else
+ return gtk_hscale_new_with_range(min, max, step);
+ #endif
+}
+
+static void
+size_request(GtkWidget* widget, GtkRequisition* req)
+{
+ #if GTK_MAJOR_VERSION == 3
+ gtk_widget_get_preferred_size(widget, NULL, req);
+ #else
+ gtk_widget_size_request(widget, req);
+ #endif
+}
+
static void
on_window_destroy(GtkWidget* widget,
gpointer data)
@@ -63,8 +97,15 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
LilvNode*
jalv_native_ui_type(Jalv* jalv)
{
+#if GTK_MAJOR_VERSION == 2
return lilv_new_uri(jalv->world,
"http://lv2plug.in/ns/extensions/ui#GtkUI");
+#elif GTK_MAJOR_VERSION == 3
+ return lilv_new_uri(jalv->world,
+ "http://lv2plug.in/ns/extensions/ui#Gtk3UI");
+#else
+ return NULL;
+#endif
}
static void
@@ -135,7 +176,7 @@ on_save_preset_activate(GtkWidget* widget, void* ptr)
free(dot_lv2);
GtkWidget* content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
- GtkBox* box = GTK_BOX(gtk_hbox_new(FALSE, 8));
+ GtkBox* box = GTK_BOX(new_box(true, 8));
GtkWidget* uri_label = gtk_label_new("URI (Optional):");
GtkWidget* uri_entry = gtk_entry_new();
@@ -342,7 +383,7 @@ make_log_slider(struct Port* port, GHashTable* points,
float lmin = logf(min);
float lmax = logf(max);
float ldft = logf(deft);
- GtkWidget* slider = gtk_hscale_new_with_range(lmin, lmax, 0.001);
+ GtkWidget* slider = new_hscale(lmin, lmax, 0.001);
gtk_scale_set_digits(GTK_SCALE(slider), 6);
gtk_range_set_value(GTK_RANGE(slider), ldft);
g_signal_connect(G_OBJECT(slider),
@@ -358,7 +399,7 @@ make_slider(struct Port* port, GHashTable* points,
bool is_int, float min, float max, float deft)
{
const double step = is_int ? 1.0 : ((max - min) / 100.0);
- GtkWidget* slider = gtk_hscale_new_with_range(min, max, step);
+ GtkWidget* slider = new_hscale(min, max, step);
gtk_range_set_value(GTK_RANGE(slider), deft);
if (points) {
g_signal_connect(G_OBJECT(slider),
@@ -516,7 +557,7 @@ jalv_open_ui(Jalv* jalv,
gtk_window_set_title(GTK_WINDOW(window), lilv_node_as_string(name));
lilv_node_free(name);
- GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
+ GtkWidget* vbox = new_box(false, 0);
GtkWidget* menu_bar = gtk_menu_bar_new();
GtkWidget* file = gtk_menu_item_new_with_mnemonic("_File");
GtkWidget* file_menu = gtk_menu_new();
@@ -576,8 +617,8 @@ jalv_open_ui(Jalv* jalv,
gtk_widget_show_all(vbox);
GtkRequisition controls_size, box_size;
- gtk_widget_size_request(GTK_WIDGET(controls), &controls_size);
- gtk_widget_size_request(GTK_WIDGET(vbox), &box_size);
+ size_request(GTK_WIDGET(controls), &controls_size);
+ size_request(GTK_WIDGET(vbox), &box_size);
gtk_window_set_default_size(
GTK_WINDOW(window),
diff --git a/wscript b/wscript
index ffad7f6..971ec43 100644
--- a/wscript
+++ b/wscript
@@ -46,6 +46,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, 'gtk+-3.0', uselib_store='GTK3',
+ atleast_version='3.0.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',
@@ -66,6 +68,8 @@ def configure(conf):
autowaf.display_msg(conf, "Gtk 2.0 support",
conf.is_defined('HAVE_GTK2'))
+ autowaf.display_msg(conf, "Gtk 3.0 support",
+ conf.is_defined('HAVE_GTK3'))
autowaf.display_msg(conf, "Gtkmm 2.0 support",
conf.is_defined('HAVE_GTKMM2'))
autowaf.display_msg(conf, "Qt 4.0 support",
@@ -86,16 +90,26 @@ def build(bld):
install_path = '${BINDIR}')
autowaf.use_lib(bld, obj, libs)
- # Gtk version
+ # Gtk2 version
if bld.is_defined('HAVE_GTK2'):
obj = bld(features = 'c cprogram',
- source = source + ' src/jalv_gtk2.c',
+ source = source + ' src/jalv_gtk.c',
target = 'jalv.gtk',
includes = ['.', 'src'],
lib = ['pthread', 'm'],
install_path = '${BINDIR}')
autowaf.use_lib(bld, obj, libs + ' GTK2')
+ # Gtk3 version
+ if bld.is_defined('HAVE_GTK3'):
+ obj = bld(features = 'c cprogram',
+ source = source + ' src/jalv_gtk.c',
+ target = 'jalv.gtk3',
+ includes = ['.', 'src'],
+ lib = ['pthread', 'm'],
+ install_path = '${BINDIR}')
+ autowaf.use_lib(bld, obj, libs + ' GTK3')
+
# Gtkmm version
if bld.is_defined('HAVE_GTKMM2'):
obj = bld(features = 'c cxx cxxprogram',