1 { Copyright (C) 2005 Bas Steendijk and Peter Green
2 For conditions of distribution and use, see copyright notice in zlib_license.txt
3 which is included in the package
4 ----------------------------------------------------------------------------- }
10 uses baseunix,unix,glib, gdk, gtk,lcore,forms,fd_utils,classes;
\r
11 //procedure lcoregtklazrun;
\r
21 tlaztimerwrapperinterface=class(ttimerwrapperinterface)
\r
23 function createwrappedtimer : tobject;override;
\r
24 // procedure setinitialevent(wrappedtimer : tobject;newvalue : boolean);override;
\r
25 procedure setontimer(wrappedtimer : tobject;newvalue:tnotifyevent);override;
\r
26 procedure setenabled(wrappedtimer : tobject;newvalue : boolean);override;
\r
27 procedure setinterval(wrappedtimer : tobject;newvalue : integer);override;
\r
30 procedure lcoregtklazinit;
\r
36 giochannels : array[0..absoloutemaxs] of pgiochannel;
\r
38 function iocallback(source:PGIOChannel; condition:TGIOCondition; data:gpointer):gboolean;cdecl;
\r
39 // return true if we want the callback to stay
\r
42 fdsrlocal , fdswlocal : fdset ;
\r
43 currentasio : tlasio ;
\r
45 fd := g_io_channel_unix_get_fd(source);
\r
47 fd_set(fd,fdsrlocal);
\r
48 fdswlocal := fdsrlocal;
\r
49 select(fd+1,@fdsrlocal,@fdswlocal,nil,0);
\r
50 if fd_isset(fd,fdsrlocal) or fd_isset(fd,fdsrlocal) then begin
\r
51 currentasio := fdreverse[fd];
\r
52 if assigned(currentasio) then begin
\r
53 currentasio.handlefdtrigger(fd_isset(currentasio.fdhandlein,fdsrlocal),fd_isset(currentasio.fdhandleout,fdswlocal));
\r
61 result := rmasterisset(fd);
\r
64 result := wmasterisset(fd);
\r
69 procedure gtkrmasterset(fd : integer);
\r
71 if not assigned(giochannels[fd]) then giochannels[fd] := g_io_channel_unix_new(fd);
\r
72 g_io_add_watch(giochannels[fd],G_IO_IN,iocallback,nil);
\r
75 procedure gtkrmasterclr(fd: integer);
\r
79 procedure gtkwmasterset(fd : integer);
\r
81 if not assigned(giochannels[fd]) then giochannels[fd] := g_io_channel_unix_new(fd);
\r
82 g_io_add_watch(giochannels[fd],G_IO_OUT,iocallback,nil);
\r
85 procedure gtkwmasterclr(fd: integer);
\r
91 procedure dotasksandsink(sender:tobject;error:word);
\r
94 taskloopback : tlloopback;
\r
96 procedure tsc.dotasksandsink(sender:tobject;error:word);
\r
98 with tlasio(sender) do begin
\r
99 sinkdata(sender,error);
\r
103 procedure gtkaddtask(ahandler:ttaskevent;aobj:tobject;awparam,alparam:longint);
\r
105 taskloopback.sendstr(' ');
\r
109 procedure lcoregtklazinit;
\r
111 onrmasterset := gtkrmasterset;
\r
112 onrmasterclr := gtkrmasterclr;
\r
113 onwmasterset := gtkwmasterset;
\r
114 onwmasterclr := gtkwmasterclr;
\r
115 onaddtask := gtkaddtask;
\r
116 taskloopback := tlloopback.create(nil);
\r
117 taskloopback.ondataavailable := sc.dotasksandsink;
\r
118 timerwrapperinterface := tlaztimerwrapperinterface.create(nil);
\r
121 function tlaztimerwrapperinterface.createwrappedtimer : tobject;
\r
123 result := ttimer.create(nil);
\r
125 procedure tlaztimerwrapperinterface.setontimer(wrappedtimer : tobject;newvalue:tnotifyevent);
\r
127 ttimer(wrappedtimer).ontimer := newvalue;
\r
129 procedure tlaztimerwrapperinterface.setenabled(wrappedtimer : tobject;newvalue : boolean);
\r
131 ttimer(wrappedtimer).enabled := newvalue;
\r
135 procedure tlaztimerwrapperinterface.setinterval(wrappedtimer : tobject;newvalue : integer);
\r
137 ttimer(wrappedtimer).interval := newvalue;
\r