From: Duncan C. <dun...@us...> - 2005-03-15 20:34:02
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/General In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13902/gtk/Graphics/UI/Gtk/General Modified Files: Structs.hsc General.chs Log Message: Structs.hsc: Define priorityHigh and priorityDefault as the correct C constants. Add priorityHighIdle and priorityDefaultIdle. General.chs: Export the two extra priority values. Add timeoutAddFull binding which is like timeoutAdd but allows you to specift the priority. Redfine timeoutAdd in terms of timeoutAddFull. Add more extensive documentation for both functions. Fix the documentation of idleAdd to reccomend the right priority. Index: General.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/General/General.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- General.chs 27 Feb 2005 19:42:06 -0000 1.4 +++ General.chs 15 Mar 2005 20:33:47 -0000 1.5 @@ -41,9 +41,12 @@ grabGetCurrent, grabRemove, priorityLow, + priorityDefaultIdle, + priorityHighIdle, priorityDefault, priorityHigh, timeoutAdd, + timeoutAddFull, timeoutRemove, idleAdd, idleRemove, @@ -62,7 +65,9 @@ {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} import Graphics.UI.Gtk.General.Enums (InputCondition(..)) -import Graphics.UI.Gtk.General.Structs (priorityLow, priorityDefault, priorityHigh) +import Graphics.UI.Gtk.General.Structs (priorityLow, priorityDefaultIdle, + priorityHighIdle, priorityDefault, + priorityHigh) {#context lib="gtk" prefix ="gtk"#} @@ -194,16 +199,40 @@ dPtr <- mkFunPtrDestructor funPtr return (funPtr, dPtr) --- | Register a function that is to be called after --- @interval@ ms have been elapsed. +-- | Sets a function to be called at regular intervals, with the default +-- priority 'priorityDefault'. The function is called repeatedly until it +-- returns @False@, after which point the timeout function will not be called +-- again. The first call to the function will be at the end of the first interval. -- --- * If the function returns @False@ it will be removed. +-- Note that timeout functions may be delayed, due to the processing of other +-- event sources. Thus they should not be relied on for precise timing. After +-- each call to the timeout function, the time of the next timeout is +-- recalculated based on the current time and the given interval (it does not +-- try to 'catch up' time lost in delays). -- timeoutAdd :: IO Bool -> Int -> IO HandlerId -timeoutAdd fun msec = do +timeoutAdd fun msec = timeoutAddFull fun priorityDefault msec + +-- | Sets a function to be called at regular intervals, with the given +-- priority. The function is called repeatedly until it returns @False@, after +-- which point the timeout function will not be called again. The first call +-- to the function will be at the end of the first interval. +-- +-- Note that timeout functions may be delayed, due to the processing of other +-- event sources. Thus they should not be relied on for precise timing. After +-- each call to the timeout function, the time of the next timeout is +-- recalculated based on the current time and the given interval (it does not +-- try to 'catch up' time lost in delays). +-- +timeoutAddFull :: IO Bool -> Int -> Int -> IO HandlerId +timeoutAddFull fun pri msec = do (funPtr, dPtr) <- makeCallback (liftM fromBool fun) - {#call unsafe g_timeout_add_full#} (fromIntegral priorityDefault) - (fromIntegral msec) funPtr nullPtr dPtr + {#call unsafe g_timeout_add_full#} + (fromIntegral pri) + (fromIntegral msec) + funPtr + nullPtr + dPtr -- | Remove a previously added timeout handler by its -- 'TimeoutId'. @@ -215,7 +244,7 @@ -- idle. -- -- * A priority can be specified via an integer. This should usually be --- 'priorityDefault'. +-- 'priorityDefaultIdle'. -- -- * If the function returns @False@ it will be removed. -- Index: Structs.hsc =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/General/Structs.hsc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Structs.hsc 12 Feb 2005 17:19:23 -0000 1.2 +++ Structs.hsc 15 Mar 2005 20:33:46 -0000 1.3 @@ -82,6 +82,8 @@ comboGetList, #endif priorityLow, + priorityDefaultIdle, + priorityHighIdle, priorityDefault, priorityHigh, drawingAreaGetDrawWindow, @@ -612,10 +614,16 @@ -- | For installing idle callbacks: Priorities. -- priorityHigh :: Int -priorityHigh = #const G_PRIORITY_HIGH_IDLE +priorityHigh = #const G_PRIORITY_HIGH priorityDefault :: Int -priorityDefault = #const G_PRIORITY_DEFAULT_IDLE +priorityDefault = #const G_PRIORITY_DEFAULT + +priorityHighIdle :: Int +priorityHighIdle = #const G_PRIORITY_HIGH_IDLE + +priorityDefaultIdle :: Int +priorityDefaultIdle = #const G_PRIORITY_DEFAULT_IDLE priorityLow :: Int priorityLow = #const G_PRIORITY_LOW |