Create and emit gtk signal

I am trying to create and emit a GTK signal:

g_signal_new("child-finished",
    G_TYPE_OBJECT,
    G_SIGNAL_RUN_FIRST,
    0,
    NULL, NULL,
    NULL,           // *** I think this is where I need to change it
    G_TYPE_NONE, 0);
g_signal_connect(G_OBJECT(myWindow), "child-finished", G_CALLBACK(MyCallback), NULL);

Here is my code that emits a signal:

gtk_signal_emit_by_name(referenceToMyWindow, "child-finished");

And here is my code that processes the signal:

void MyCallback(GtkWidget *w, GdkEvent *e)
{
    // handler code here
}

When I run the code, I get the following error:

GLib-GObject-CRITICAL **: g _closure_invoke: statement `close-> marshal || close-> meta_marshal 'failed

I know that this is connected with the transfer of the marshaller to a function g_signal_new, but I don’t know what a marshaller is, I can’t understand the documentation , and there are not many examples on the Internet. How to announce and connect your own signal?

+3
source share
1 answer

GObject , :

g_signal_new("child-finished",
             G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST,
             0, NULL, NULL,
             g_cclosure_marshal_VOID__POINTER,
             G_TYPE_NONE, 1, G_TYPE_POINTER);

, :

g_signal_new("child-finished",
             G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST,
             0, NULL, NULL,
             g_cclosure_marshal_VOID__BOXED,
             G_TYPE_NONE, 1, GDK_TYPE_EVENT);

( ), ( ) ( ).

, glib-genmarshal ( , glib-genmarshal).

+3

Source: https://habr.com/ru/post/1719925/


All Articles