diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2016-05-17 22:11:17 +0200 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2016-05-17 22:11:17 +0200 |
| commit | ace28857b70d8a8fe97cdf29f937614eb13de781 (patch) | |
| tree | 11c759eaec999dd5a934797546b35a1fa5d42179 /gtk/ScintillaGTK.cxx | |
| parent | 99d52264a609b61e8639f3c1087a78fedb0b9de8 (diff) | |
| download | scintilla-mirror-ace28857b70d8a8fe97cdf29f937614eb13de781.tar.gz | |
Enable g-ir-scanner to scan ScintillaObject signals
Currently, the ScintillaObject signals can't be used from python code via
gobject-introspection. This is because g-ir-scanner does not properly scan
the signals.
For signals, there is the additional requirement that parameters have are
registered GTypes. For the sci-notify signal, this can be accomplished by
boxing SCNotification.
In addition, g-ir-scanner also runs on Scintilla.h where it picks up
additional structs.
test/gi/ is updated accordingly. The test python script is enhanced
to showcase the signals (some fixes to the makefile are included as well).
Diffstat (limited to 'gtk/ScintillaGTK.cxx')
| -rw-r--r-- | gtk/ScintillaGTK.cxx | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 9fc8e4cc4..f9adbc9ce 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -3162,9 +3162,6 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_ container_class->forall = MainForAll; } -#define SIG_MARSHAL scintilla_marshal_NONE__INT_POINTER -#define MARSHAL_ARGUMENTS G_TYPE_INT, G_TYPE_POINTER - static void scintilla_class_init(ScintillaClass *klass) { try { OBJECT_CLASS *object_class = (OBJECT_CLASS*) klass; @@ -3179,20 +3176,20 @@ static void scintilla_class_init(ScintillaClass *klass) { G_STRUCT_OFFSET(ScintillaClass, command), NULL, //(GSignalAccumulator) NULL, //(gpointer) - SIG_MARSHAL, + scintilla_marshal_VOID__INT_OBJECT, G_TYPE_NONE, - 2, MARSHAL_ARGUMENTS); + 2, G_TYPE_INT, GTK_TYPE_WIDGET); scintilla_signals[NOTIFY_SIGNAL] = g_signal_new( SCINTILLA_NOTIFY, G_TYPE_FROM_CLASS(object_class), sigflags, G_STRUCT_OFFSET(ScintillaClass, notify), - NULL, - NULL, - SIG_MARSHAL, + NULL, //(GSignalAccumulator) + NULL, //(gpointer) + scintilla_marshal_VOID__INT_BOXED, G_TYPE_NONE, - 2, MARSHAL_ARGUMENTS); + 2, G_TYPE_INT, SCINTILLA_TYPE_NOTIFICATION); klass->command = NULL; klass->notify = NULL; @@ -3233,3 +3230,23 @@ void scintilla_release_resources(void) { } catch (...) { } } + +/* Define a dummy boxed type because g-ir-scanner is unable to + * recognize gpointer-derived types. Note that SCNotificaiton + * is always allocated on stack so copying is not appropriate. */ +static void *copy_(void *src) { return src; } +static void free_(void *doc) { } + +GType scnotification_get_type(void) +{ + static gsize type_id = 0; + if (g_once_init_enter (&type_id)) + { + gsize id = (gsize) g_boxed_type_register_static( + g_intern_static_string ("SCNotification"), + (GBoxedCopyFunc) copy_, + (GBoxedFreeFunc) free_); + g_once_init_leave(&type_id, id); + } + return (GType) type_id; +} |
