implement calling event for handle activity in main loop for gtk

git-svn-id: trunk@8169 -
This commit is contained in:
micha 2005-11-15 17:30:03 +00:00
parent ed60dffb71
commit a02ab953ca
4 changed files with 60 additions and 3 deletions

View File

@ -81,8 +81,8 @@ uses
{$ENDIF}
// LCL
ExtDlgs, Dialogs, Controls, Forms, LCLStrConsts, LMessages,
LCLProc, LCLIntf, LCLType, gtkDef, DynHashArray, gtkMsgQueue,
GraphType, GraphMath, Graphics, Menus;
LCLProc, LCLIntf, LCLType, gtkDef, GtkProc, DynHashArray,
gtkMsgQueue, GraphType, GraphMath, Graphics, Menus;
type
@ -113,6 +113,8 @@ type
FStockBlackPen: HPEN;
FStockWhitePen: HPEN;
FWaitHandles: PWaitHandleEventHandler;
{$Ifdef GTK2}
FDefaultFontDesc: PPangoFontDescription;
{$Else}
@ -338,7 +340,7 @@ uses
////////////////////////////////////////////////////
Buttons, StdCtrls, PairSplitter, Math,
GTKWinApiWindow, ComCtrls, CListBox, Calendar, Arrow, Spin, CommCtrl,
ExtCtrls, FileCtrl, LResources, gtkglobals, gtkproc;
ExtCtrls, FileCtrl, LResources, gtkglobals;
const
GtkNil = nil;

View File

@ -29,6 +29,48 @@
//##apiwiz##sps## // Do not remove
function waithandle_iocallback(source: PGIOChannel; condition: TGIOCondition;
data: gpointer): gboolean; cdecl;
begin
TNotifyEvent(data^)(WidgetSet);
end;
procedure TGtkWidgetSet.AddEventHandler(AHandle: THandle; AEventHandler: TNotifyEvent);
var
giochannel: pgiochannel;
lEventHandler: PWaitHandleEventHandler;
begin
New(lEventHandler);
giochannel := g_io_channel_unix_new(AHandle);
lEventHandler^.Handle := AHandle;
lEventHandler^.GIOChannel := giochannel;
lEventHandler^.OnEvent := AEventHandler;
lEventHandler^.GSourceID := g_io_add_watch(giochannel,
G_IO_IN, @waithandle_iocallback, @lEventHandler^.OnEvent);
lEventHandler^.NextHandler := FWaitHandles;
FWaitHandles := lEventHandler;
end;
procedure TGtkWidgetSet.RemoveEventHandler(AHandle: THandle);
var
lEventHandler: PWaitHandleEventHandler;
lPrevEventHandler: PPWaitHandleEventHandler;
begin
lPrevEventHandler := @FWaitHandles;
while lPrevEventHandler^ <> nil do
begin
lEventHandler := lPrevEventHandler^;
if lEventHandler^.Handle = AHandle then
begin
g_source_remove(lEventHandler^.GSourceID);
lPrevEventHandler^ := lEventHandler^.NextHandler;
Dispose(lEventHandler);
exit;
end;
lPrevEventHandler := @lEventHandler^.NextHandler;
end;
end;
{------------------------------------------------------------------------------
function TGtkWidgetSet.DrawSplitter(DC: HDC; const ARect: TRect;
Horizontal: boolean): Integer;

View File

@ -29,6 +29,7 @@
}
//##apiwiz##sps## // Do not remove
procedure AddEventHandler(AHandle: THandle; AEventHandler: TNotifyEvent); override;
function DrawSplitter(DC: HDC; const ARect: TRect; Horizontal: boolean): boolean; override;
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
@ -44,6 +45,7 @@ function GetListBoxItemRect(ListBox: TComponent; Index: integer; var ARect: TRec
function IntfSendsUTF8KeyPress: boolean; override;
procedure RemoveEventHandler(AHandle: THandle); override;
function ReplaceBitmapMask(var Image, Mask: HBitmap; NewMask: HBitmap): boolean; override;
//##apiwiz##eps## // Do not remove, no wizard declaration after this line

View File

@ -57,6 +57,17 @@ uses
FileUtil, ImgList, GTKGlobals, gtkDef;
type
PPWaitHandleEventHandler = ^PWaitHandleEventHandler;
PWaitHandleEventHandler = ^TWaitHandleEventHandler;
TWaitHandleEventHandler = record
Handle: THandle;
GIOChannel: pgiochannel;
GSourceID: guint;
OnEvent: TNotifyEvent;
NextHandler: PWaitHandleEventHandler;
end;
{$IFDEF gtk2}
const
gdkdll = gdklib;