diff options
author | David Robillard <d@drobilla.net> | 2020-12-26 19:24:15 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-12-31 13:37:55 +0100 |
commit | 9f5fb1cf1b3df6a86d6571886169455d9d9ec393 (patch) | |
tree | 0e7515a3d319eb06b5450e3482055fc269503f1c /src/gtk2_in_qt4.cpp | |
parent | 1fece68f494158fff81fd3dca5a928860d5a6376 (diff) | |
download | suil-9f5fb1cf1b3df6a86d6571886169455d9d9ec393.tar.gz suil-9f5fb1cf1b3df6a86d6571886169455d9d9ec393.tar.bz2 suil-9f5fb1cf1b3df6a86d6571886169455d9d9ec393.zip |
Format all code with clang-format
Diffstat (limited to 'src/gtk2_in_qt4.cpp')
-rw-r--r-- | src/gtk2_in_qt4.cpp | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/src/gtk2_in_qt4.cpp b/src/gtk2_in_qt4.cpp index 2bb3a03..ddf174f 100644 --- a/src/gtk2_in_qt4.cpp +++ b/src/gtk2_in_qt4.cpp @@ -22,17 +22,17 @@ #undef signals -#include <gtk/gtk.h> #include <gdk/gdkx.h> +#include <gtk/gtk.h> extern "C" { using SuilGtk2InQt4Wrapper = _SuilGtk2InQt4Wrapper; struct _SuilGtk2InQt4Wrapper { - QX11EmbedContainer* host_widget; - QWidget* parent; - GtkWidget* plug; + QX11EmbedContainer* host_widget; + QWidget* parent; + GtkWidget* plug; }; static void @@ -40,8 +40,8 @@ on_size_request(GtkWidget* widget, GtkRequisition* requisition, gpointer user_data) { - QX11EmbedContainer* const wrap = (QX11EmbedContainer*)user_data; - wrap->setMinimumSize(requisition->width, requisition->height); + QX11EmbedContainer* const wrap = (QX11EmbedContainer*)user_data; + wrap->setMinimumSize(requisition->width, requisition->height); } static void @@ -49,58 +49,57 @@ on_size_allocate(GtkWidget* widget, GdkRectangle* allocation, gpointer user_data) { - QX11EmbedContainer* const wrap = (QX11EmbedContainer*)user_data; - wrap->resize(allocation->width, allocation->height); + QX11EmbedContainer* const wrap = (QX11EmbedContainer*)user_data; + wrap->resize(allocation->width, allocation->height); } static void wrapper_free(SuilWrapper* wrapper) { - SuilGtk2InQt4Wrapper* impl = (SuilGtk2InQt4Wrapper*)wrapper->impl; + SuilGtk2InQt4Wrapper* impl = (SuilGtk2InQt4Wrapper*)wrapper->impl; - if (impl->plug) { - gtk_widget_destroy(impl->plug); - } + if (impl->plug) { + gtk_widget_destroy(impl->plug); + } - if (impl->host_widget) { - delete impl->host_widget; - } + if (impl->host_widget) { + delete impl->host_widget; + } - free(impl); + free(impl); } static int -wrapper_wrap(SuilWrapper* wrapper, - SuilInstance* instance) +wrapper_wrap(SuilWrapper* wrapper, SuilInstance* instance) { - SuilGtk2InQt4Wrapper* const impl = (SuilGtk2InQt4Wrapper*)wrapper->impl; - QWidget* root = static_cast<QWidget*>(impl->parent); - QX11EmbedContainer* const wrap = new QX11EmbedContainer(root); - GtkWidget* const plug = gtk_plug_new(wrap->winId()); - GtkWidget* const widget = (GtkWidget*)instance->ui_widget; + SuilGtk2InQt4Wrapper* const impl = (SuilGtk2InQt4Wrapper*)wrapper->impl; + QWidget* root = static_cast<QWidget*>(impl->parent); + QX11EmbedContainer* const wrap = new QX11EmbedContainer(root); + GtkWidget* const plug = gtk_plug_new(wrap->winId()); + GtkWidget* const widget = (GtkWidget*)instance->ui_widget; - gtk_container_add(GTK_CONTAINER(plug), widget); - gtk_widget_show_all(plug); + gtk_container_add(GTK_CONTAINER(plug), widget); + gtk_widget_show_all(plug); #ifdef SUIL_OLD_GTK - wrap->resize(widget->allocation.width, widget->allocation.height); + wrap->resize(widget->allocation.width, widget->allocation.height); #else - GtkAllocation alloc; - gtk_widget_get_allocation(widget, &alloc); - wrap->resize(alloc.width, alloc.height); + GtkAllocation alloc; + gtk_widget_get_allocation(widget, &alloc); + wrap->resize(alloc.width, alloc.height); #endif - g_signal_connect( - G_OBJECT(plug), "size-request", G_CALLBACK(on_size_request), wrap); + g_signal_connect( + G_OBJECT(plug), "size-request", G_CALLBACK(on_size_request), wrap); - g_signal_connect( - G_OBJECT(plug), "size-allocate", G_CALLBACK(on_size_allocate), wrap); + g_signal_connect( + G_OBJECT(plug), "size-allocate", G_CALLBACK(on_size_allocate), wrap); - impl->host_widget = wrap; - impl->plug = plug; - instance->host_widget = wrap; + impl->host_widget = wrap; + impl->plug = plug; + instance->host_widget = wrap; - return 0; + return 0; } SUIL_LIB_EXPORT @@ -111,39 +110,40 @@ suil_wrapper_new(SuilHost* host, LV2_Feature*** features, unsigned n_features) { - /* 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) { - dylib_error(); - host->gtk_lib = dylib_open(SUIL_GTK2_LIB_NAME, DYLIB_LAZY|DYLIB_GLOBAL); - if (!host->gtk_lib) { - SUIL_ERRORF("Failed to open %s (%s)\n", - SUIL_GTK2_LIB_NAME, dylib_error()); - return nullptr; - } - gtk_init(nullptr, nullptr); - } - - /* Create wrapper implementation. */ - SuilGtk2InQt4Wrapper* const impl = (SuilGtk2InQt4Wrapper*) - calloc(1, sizeof(SuilGtk2InQt4Wrapper)); - - /* Set parent widget if given. */ - for (unsigned i = 0; i < n_features; ++i) { - if (!strcmp((*features)[i]->URI, LV2_UI__parent)) { - impl->parent = static_cast<QWidget*>((*features)[i]->data); - } - } - - SuilWrapper* wrapper = (SuilWrapper*)calloc(1, sizeof(SuilWrapper)); - wrapper->wrap = wrapper_wrap; - wrapper->free = wrapper_free; - wrapper->impl = impl; - - return wrapper; + /* 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) { + dylib_error(); + host->gtk_lib = dylib_open(SUIL_GTK2_LIB_NAME, DYLIB_LAZY | DYLIB_GLOBAL); + if (!host->gtk_lib) { + SUIL_ERRORF( + "Failed to open %s (%s)\n", SUIL_GTK2_LIB_NAME, dylib_error()); + return nullptr; + } + + gtk_init(nullptr, nullptr); + } + + /* Create wrapper implementation. */ + SuilGtk2InQt4Wrapper* const impl = + (SuilGtk2InQt4Wrapper*)calloc(1, sizeof(SuilGtk2InQt4Wrapper)); + + /* Set parent widget if given. */ + for (unsigned i = 0; i < n_features; ++i) { + if (!strcmp((*features)[i]->URI, LV2_UI__parent)) { + impl->parent = static_cast<QWidget*>((*features)[i]->data); + } + } + + SuilWrapper* wrapper = (SuilWrapper*)calloc(1, sizeof(SuilWrapper)); + wrapper->wrap = wrapper_wrap; + wrapper->free = wrapper_free; + wrapper->impl = impl; + + return wrapper; } -} // extern "C" +} // extern "C" |