gi-server

Unnamed repository; edit this file 'description' to name the repository.
git clone https://logand.com/git/gi-server.git/
Log | Files | Refs

commit a03dc873563492dd715ccf846002af9c67ec31a9
parent 337da032e5745233816d9b2a66a547daf89ebdfa
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun,  6 Sep 2015 10:54:40 +0200

basic support for signals

Diffstat:
Mgi-server.c | 33+++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+), 0 deletions(-)

diff --git a/gi-server.c b/gi-server.c @@ -101,8 +101,16 @@ static void to_argument(GIArgument *z, GIArgInfo *ai, GITypeInfo ti) { } } +static long event; + +static void handler(gpointer *object, gpointer *data) { + event = (long) data; +} + int main(void) { GIRepository *r = g_irepository_get_default(); + long id = 0; + event = 0; for(;;) { top = heap; fflush(stdout); @@ -194,6 +202,31 @@ int main(void) { if(p) printf("ok %ld\n", (unsigned long) p); else printf("error in vfunc: %s\n", name); } + else if(!strcmp("connect", cmd)) { + gpointer* object = pointer(); + gchar* signal = token(); + int after = integer(); + gulong z; + if(after) + z = g_signal_connect_after(object, signal, G_CALLBACK(handler), (gpointer) ++id); + else + z = g_signal_connect(object, signal, G_CALLBACK(handler), (gpointer) ++id); + if(0 < z) printf("ok %ld\n", id); + else printf("error in connect: %s\n", signal); + } + else if(!strcmp("callback", cmd)) { + printf("ok %ld\n", event); + event = 0; + } + else if(!strcmp("class", cmd)) { + gpointer* object = pointer(); + printf("ok %ld\n", (long) G_OBJECT_GET_CLASS(object)); + } + else if(!strcmp("exit", cmd)) { + printf("ok\n"); + fflush(stdout); + return 0; + } } return 0; }