   toEventListener a = a
 
 foreign import ccall unsafe "gtk2hs_closure_new"
-  gtk2hs_closure_new :: StablePtr a -> IO (Ptr EventListener)
+  gtk2hs_closure_new :: StablePtr a -> IO (Ptr GClosure)
 
 eventListenerNew :: EventClass event => (event -> IO ()) -> IO EventListener
-eventListenerNew callback = do -- EventListener . castRef <$> syncCallback1 AlwaysRetain True (callback . unsafeCastGObject . GObject)
+eventListenerNew callback = do
   sptr <- newStablePtr action
   gclosurePtr <- gtk2hs_closure_new sptr
-  return $ EventListener gclosurePtr
+  return $ EventListener gclosurePtr sptr
   where action :: Ptr GObject -> Ptr GObject -> IO ()
         action obj1 obj2 =
           failOnGError $

          makeNewGObject (GObject, objectUnrefFromMainloop) (return obj1) >>= \obj1' ->
          callback (unsafeCastGObject obj2')


{-# LANGUAGE CPP #-}
{-# CFILES events.c #-}
module Graphics.UI.Gtk.WebKit.DOM.EventTargetClosures
       (EventName(..), SaferEventListener(..), EventListener(..), unEventListener, EventListenerClass(..),
       eventListenerNew, eventListenerNewAsync, eventListenerNewSync, eventListenerRelease) where
import Control.Monad.Reader (ReaderT)
import System.Glib.FFI (newStablePtr, freeStablePtr, StablePtr, Ptr(..), toBool, CInt(..), CChar,
        withForeignPtr, fromBool)
import System.Glib.UTFString
import Control.Applicative
