    {-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-}
    -- | This module implements a TrayManager - an integral part of a
    -- Linux system tray widget, though it is not itself a widget.  This
    -- package exports a single GObject (for use with gtk2hs) that
    -- implements the freedesktop.org system tray specification (it
    -- handles receiving events and translating them into convenient
    -- signals, along with the messy work of dealing with XEMBED).
    --
    -- The basic usage of the object is to:
    --
    -- 1. Instantiate the object with 'trayManagerNew'
    --
    -- 2. Have it manage a specific screen with 'trayManagerManageScreen'
    --
    -- 3. Set up handlers for the events exposed by the tray (e.g., 'trayIconAdded').
    --
    -- As an example, a functional system tray widget looks something like:
    --
    -- > import Graphics.UI.Gtk
    -- > import Graphics.UI.Gtk.Misc.TrayManager
    -- > systrayNew = do
    -- >   box <- hBoxNew False 5
    -- >   trayManager <- rayManagerNew
    -- >   Just screen <- screenGetDefault
    -- >   trayManagerManageScreen trayManager screen
    -- >   on trayManager trayIconAdded $ \w -> do
    -- >     widgetShowAll w
    -- >     boxPackStart box w PackNatural 0
    --
    -- Note that the widgets made available in the event handlers are not
    -- shown by default; you need to explicitly show them if you want that
    -- (and you probably do).
    module Graphics.UI.Gtk.Misc.TrayManager (
      -- * Types
      TrayManager,
      TrayManagerChild,
      TrayManagerClass,
      castToTrayManager,
      toTrayManager,
      gTypeTrayManager,

      -- * Functions
      trayManagerCheckRunning,
      trayManagerNew,
      trayManagerManageScreen,
      trayManagerGetChildTitle,

      -- * Signals
      trayIconAdded,
      trayIconRemoved,
      trayMessageSent,
      trayMessageCanceled,
      trayLostSelection
      ) where

    import Graphics.UI.Gtk hiding ( after )
    import Graphics.UI.Gtk.Abstract.Object ( makeNewObject )
    import Graphics.UI.GtkInternals
    import System.Glib.GError ( failOnGError )
    import System.Glib.GType
    import System.Glib.UTFString ( peekUTFString )

    import Control.Monad ( liftM )

    import Foreign
    import Foreign.C.String ( CString, peekCString )
    import Foreign.C.Types
    import Foreign.ForeignPtr.Unsafe as UF
    import Unsafe.Coerce ( unsafeCoerce )

    newtype TrayManager = TrayManager (ForeignPtr TrayManager)
                        deriving (TrayManager -> TrayManager -> Bool
    (TrayManager -> TrayManager -> Bool)
    -> (TrayManager -> TrayManager -> Bool) -> Eq TrayManager
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TrayManager -> TrayManager -> Bool
    == :: TrayManager -> TrayManager -> Bool
    $c/= :: TrayManager -> TrayManager -> Bool
    /= :: TrayManager -> TrayManager -> Bool
    Eq, Eq TrayManager
    Eq TrayManager =>
    (TrayManager -> TrayManager -> Ordering)
    -> (TrayManager -> TrayManager -> Bool)
    -> (TrayManager -> TrayManager -> Bool)
    -> (TrayManager -> TrayManager -> Bool)
    -> (TrayManager -> TrayManager -> Bool)
    -> (TrayManager -> TrayManager -> TrayManager)
    -> (TrayManager -> TrayManager -> TrayManager)
    -> Ord TrayManager
    TrayManager -> TrayManager -> Bool
    TrayManager -> TrayManager -> Ordering
    TrayManager -> TrayManager -> TrayManager
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: TrayManager -> TrayManager -> Ordering
    compare :: TrayManager -> TrayManager -> Ordering
    $c< :: TrayManager -> TrayManager -> Bool
    < :: TrayManager -> TrayManager -> Bool
    $c<= :: TrayManager -> TrayManager -> Bool
    <= :: TrayManager -> TrayManager -> Bool
    $c> :: TrayManager -> TrayManager -> Bool
    > :: TrayManager -> TrayManager -> Bool
    $c>= :: TrayManager -> TrayManager -> Bool
    >= :: TrayManager -> TrayManager -> Bool
    $cmax :: TrayManager -> TrayManager -> TrayManager
    max :: TrayManager -> TrayManager -> TrayManager
    $cmin :: TrayManager -> TrayManager -> TrayManager
    min :: TrayManager -> TrayManager -> TrayManager
    Ord)
    type TrayManagerChild = Ptr EggTrayManagerChild

    -- Empty data tags to classify some foreign pointers
    data EggTrayManager
    data EggTrayManagerChild

    foreign import ccall "egg_tray_manager_check_running"
      c_egg_tray_manager_check_running :: Ptr Screen -> IO CInt

    trayManagerCheckRunning :: Screen -> IO Bool
    trayManagerCheckRunning :: Screen -> IO Bool
    trayManagerCheckRunning Screen
    gdkScreen = do
      let ptrScreen :: ForeignPtr Screen
    ptrScreen = Screen -> ForeignPtr Screen
    forall a b. a -> b
    unsafeCoerce Screen
    gdkScreen :: ForeignPtr Screen
      ForeignPtr Screen -> (Ptr Screen -> IO Bool) -> IO Bool
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr Screen
    ptrScreen ((Ptr Screen -> IO Bool) -> IO Bool)
    -> (Ptr Screen -> IO Bool) -> IO Bool
    forall a b. (a -> b) -> a -> b
    $ \Ptr Screen
    realPtr -> do
        res <- Ptr Screen -> IO CInt
    c_egg_tray_manager_check_running Ptr Screen
    realPtr
        return (res /= 0)

    mkTrayManager :: (ForeignPtr TrayManager -> TrayManager, FinalizerPtr a)
    mkTrayManager :: forall a. (ForeignPtr TrayManager -> TrayManager, FinalizerPtr a)
    mkTrayManager = (ForeignPtr TrayManager -> TrayManager
    TrayManager, FinalizerPtr a
    forall a. FinalizerPtr a
    objectUnrefFromMainloop)

    unTrayManager :: TrayManager -> ForeignPtr TrayManager
    unTrayManager :: TrayManager -> ForeignPtr TrayManager
    unTrayManager (TrayManager ForeignPtr TrayManager
    o) = ForeignPtr TrayManager
    o

    class GObjectClass o => TrayManagerClass o
    toTrayManager :: TrayManagerClass o => o -> TrayManager
    toTrayManager :: forall o. TrayManagerClass o => o -> TrayManager
    toTrayManager = GObject -> TrayManager
    forall o. GObjectClass o => GObject -> o
    unsafeCastGObject (GObject -> TrayManager) -> (o -> GObject) -> o -> TrayManager
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . o -> GObject
    forall o. GObjectClass o => o -> GObject
    toGObject

    instance TrayManagerClass TrayManager
    instance GObjectClass TrayManager where
      toGObject :: TrayManager -> GObject
    toGObject = ForeignPtr GObject -> GObject
    GObject (ForeignPtr GObject -> GObject)
    -> (TrayManager -> ForeignPtr GObject) -> TrayManager -> GObject
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ForeignPtr TrayManager -> ForeignPtr GObject
    forall a b. ForeignPtr a -> ForeignPtr b
    castForeignPtr (ForeignPtr TrayManager -> ForeignPtr GObject)
    -> (TrayManager -> ForeignPtr TrayManager)
    -> TrayManager
    -> ForeignPtr GObject
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TrayManager -> ForeignPtr TrayManager
    unTrayManager
      unsafeCastGObject :: GObject -> TrayManager
    unsafeCastGObject = ForeignPtr TrayManager -> TrayManager
    TrayManager (ForeignPtr TrayManager -> TrayManager)
    -> (GObject -> ForeignPtr TrayManager) -> GObject -> TrayManager
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ForeignPtr GObject -> ForeignPtr TrayManager
    forall a b. ForeignPtr a -> ForeignPtr b
    castForeignPtr (ForeignPtr GObject -> ForeignPtr TrayManager)
    -> (GObject -> ForeignPtr GObject)
    -> GObject
    -> ForeignPtr TrayManager
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . GObject -> ForeignPtr GObject
    unGObject

    castToTrayManager :: GObjectClass o => o -> TrayManager
    castToTrayManager :: forall o. GObjectClass o => o -> TrayManager
    castToTrayManager = CULong -> String -> o -> TrayManager
    forall obj obj'.
    (GObjectClass obj, GObjectClass obj') =>
    CULong -> String -> obj -> obj'
    castTo CULong
    gTypeTrayManager String
    "TrayManager"

    foreign import ccall "egg_tray_manager_get_type"
      c_egg_tray_manager_get_type :: CULong

    gTypeTrayManager :: GType
    gTypeTrayManager :: CULong
    gTypeTrayManager = CULong -> CULong
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral CULong
    c_egg_tray_manager_get_type

    foreign import ccall "egg_tray_manager_new"
      c_egg_tray_manager_new :: IO (Ptr EggTrayManager)

    trayManagerNew :: IO TrayManager
    trayManagerNew :: IO TrayManager
    trayManagerNew =
      (ForeignPtr TrayManager -> TrayManager, FinalizerPtr TrayManager)
    -> IO (Ptr TrayManager) -> IO TrayManager
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewObject (ForeignPtr TrayManager -> TrayManager, FinalizerPtr TrayManager)
    forall a. (ForeignPtr TrayManager -> TrayManager, FinalizerPtr a)
    mkTrayManager (IO (Ptr TrayManager) -> IO TrayManager)
    -> IO (Ptr TrayManager) -> IO TrayManager
    forall a b. (a -> b) -> a -> b
    $ (Ptr EggTrayManager -> Ptr TrayManager)
    -> IO (Ptr EggTrayManager) -> IO (Ptr TrayManager)
    forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
    liftM (Ptr EggTrayManager -> Ptr TrayManager
    forall a b. Ptr a -> Ptr b
    castPtr :: Ptr EggTrayManager -> Ptr TrayManager) (IO (Ptr EggTrayManager) -> IO (Ptr TrayManager))
    -> IO (Ptr EggTrayManager) -> IO (Ptr TrayManager)
    forall a b. (a -> b) -> a -> b
    $
        IO (Ptr EggTrayManager)
    c_egg_tray_manager_new
      -- tm <- c_egg_tray_manager_new
      -- return (unsafeCoerce tm)

    foreign import ccall "egg_tray_manager_manage_screen"
      c_egg_tray_manager_manage_screen :: Ptr EggTrayManager -> Ptr Screen -> IO CInt

    trayManagerManageScreen :: TrayManager -> Screen -> IO Bool
    trayManagerManageScreen :: TrayManager -> Screen -> IO Bool
    trayManagerManageScreen TrayManager
    trayManager Screen
    screen = do
      let ptrManager :: ForeignPtr EggTrayManager
    ptrManager = TrayManager -> ForeignPtr EggTrayManager
    forall a b. a -> b
    unsafeCoerce TrayManager
    trayManager :: ForeignPtr EggTrayManager
          ptrScreen :: ForeignPtr Screen
    ptrScreen = Screen -> ForeignPtr Screen
    forall a b. a -> b
    unsafeCoerce Screen
    screen :: ForeignPtr Screen
      res <- ForeignPtr EggTrayManager
    -> (Ptr EggTrayManager -> IO CInt) -> IO CInt
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr EggTrayManager
    ptrManager ((Ptr EggTrayManager -> IO CInt) -> IO CInt)
    -> (Ptr EggTrayManager -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr EggTrayManager
    realManager -> do
        ForeignPtr Screen -> (Ptr Screen -> IO CInt) -> IO CInt
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr Screen
    ptrScreen ((Ptr Screen -> IO CInt) -> IO CInt)
    -> (Ptr Screen -> IO CInt) -> IO CInt
    forall a b. (a -> b) -> a -> b
    $ \Ptr Screen
    realScreen -> do
          Ptr EggTrayManager -> Ptr Screen -> IO CInt
    c_egg_tray_manager_manage_screen Ptr EggTrayManager
    realManager Ptr Screen
    realScreen
      return (res /= 0)

    foreign import ccall "egg_tray_manager_get_child_title"
      c_egg_tray_manager_get_child_title :: Ptr EggTrayManager -> Ptr EggTrayManagerChild -> IO (Ptr CChar)

    trayManagerGetChildTitle :: TrayManager -> TrayManagerChild -> IO String
    trayManagerGetChildTitle :: TrayManager -> TrayManagerChild -> IO String
    trayManagerGetChildTitle TrayManager
    trayManager TrayManagerChild
    child = do
      let ptrManager :: ForeignPtr EggTrayManager
    ptrManager = TrayManager -> ForeignPtr EggTrayManager
    forall a b. a -> b
    unsafeCoerce TrayManager
    trayManager :: ForeignPtr EggTrayManager
      res <- ForeignPtr EggTrayManager
    -> (Ptr EggTrayManager -> IO (Ptr CChar)) -> IO (Ptr CChar)
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
    withForeignPtr ForeignPtr EggTrayManager
    ptrManager ((Ptr EggTrayManager -> IO (Ptr CChar)) -> IO (Ptr CChar))
    -> (Ptr EggTrayManager -> IO (Ptr CChar)) -> IO (Ptr CChar)
    forall a b. (a -> b) -> a -> b
    $ \Ptr EggTrayManager
    realManager -> do
        Ptr EggTrayManager -> TrayManagerChild -> IO (Ptr CChar)
    c_egg_tray_manager_get_child_title Ptr EggTrayManager
    realManager TrayManagerChild
    child
      peekCString res

    -- | The signal emitted when a new tray icon is added.  These are
    -- delivered even for systray icons that already exist when the tray
    -- manager is created.
    trayIconAdded :: (TrayManagerClass self) => Signal self (Widget -> IO ())
    trayIconAdded :: forall self. TrayManagerClass self => Signal self (Widget -> IO ())
    trayIconAdded = (Bool -> self -> (Widget -> IO ()) -> IO (ConnectId self))
    -> Signal self (Widget -> IO ())
    forall object handler.
    (Bool -> object -> handler -> IO (ConnectId object))
    -> Signal object handler
    Signal (String -> Bool -> self -> (Widget -> IO ()) -> IO (ConnectId self)
    forall a' obj.
    (GObjectClass a', GObjectClass obj) =>
    String -> Bool -> obj -> (a' -> IO ()) -> IO (ConnectId obj)
    connect_OBJECT__NONE String
    "tray_icon_added")

    -- | This signal is emitted when a tray icon is removed by its parent
    -- application.  No action is really necessary here (the icon is
    -- removed without any intervention).  You could do something here if
    -- you wanted, though.
    trayIconRemoved :: (TrayManagerClass self) => Signal self (Widget -> IO ())
    trayIconRemoved :: forall self. TrayManagerClass self => Signal self (Widget -> IO ())
    trayIconRemoved = (Bool -> self -> (Widget -> IO ()) -> IO (ConnectId self))
    -> Signal self (Widget -> IO ())
    forall object handler.
    (Bool -> object -> handler -> IO (ConnectId object))
    -> Signal object handler
    Signal (String -> Bool -> self -> (Widget -> IO ()) -> IO (ConnectId self)
    forall a' obj.
    (GObjectClass a', GObjectClass obj) =>
    String -> Bool -> obj -> (a' -> IO ()) -> IO (ConnectId obj)
    connect_OBJECT__NONE String
    "tray_icon_removed")

    -- | This signal is emitted when the application that displayed an
    -- icon wants a semi-persistent notification displayed for its icon.
    -- The standard doesn't seem to require that these be honored.
    trayMessageSent :: (TrayManagerClass self) => Signal self (Widget -> String -> Int64 -> Int64 -> IO ())
    trayMessageSent :: forall self.
    TrayManagerClass self =>
    Signal self (Widget -> String -> Int64 -> Int64 -> IO ())
    trayMessageSent = (Bool
     -> self
     -> (Widget -> String -> Int64 -> Int64 -> IO ())
     -> IO (ConnectId self))
    -> Signal self (Widget -> String -> Int64 -> Int64 -> IO ())
    forall object handler.
    (Bool -> object -> handler -> IO (ConnectId object))
    -> Signal object handler
    Signal (String
    -> Bool
    -> self
    -> (Widget -> String -> Int64 -> Int64 -> IO ())
    -> IO (ConnectId self)
    forall a' obj.
    (GObjectClass a', GObjectClass obj) =>
    String
    -> Bool
    -> obj
    -> (a' -> String -> Int64 -> Int64 -> IO ())
    -> IO (ConnectId obj)
    connect_OBJECT_STRING_INT64_INT64__NONE String
    "message_sent")

    -- | Similarly, the applciation can send this to cancel a previous
    -- persistent message.
    trayMessageCanceled :: (TrayManagerClass self) => Signal self (Widget -> Int64 -> IO ())
    trayMessageCanceled :: forall self.
    TrayManagerClass self =>
    Signal self (Widget -> Int64 -> IO ())
    trayMessageCanceled = (Bool -> self -> (Widget -> Int64 -> IO ()) -> IO (ConnectId self))
    -> Signal self (Widget -> Int64 -> IO ())
    forall object handler.
    (Bool -> object -> handler -> IO (ConnectId object))
    -> Signal object handler
    Signal (String
    -> Bool
    -> self
    -> (Widget -> Int64 -> IO ())
    -> IO (ConnectId self)
    forall a' obj.
    (GObjectClass a', GObjectClass obj) =>
    String
    -> Bool -> obj -> (a' -> Int64 -> IO ()) -> IO (ConnectId obj)
    connect_OBJECT_INT64__NONE String
    "message_canceled")

    -- | ??
    trayLostSelection :: (TrayManagerClass self) => Signal self (IO ())
    trayLostSelection :: forall self. TrayManagerClass self => Signal self (IO ())
    trayLostSelection = (Bool -> self -> IO () -> IO (ConnectId self))
    -> Signal self (IO ())
    forall object handler.
    (Bool -> object -> handler -> IO (ConnectId object))
    -> Signal object handler
    Signal (String -> Bool -> self -> IO () -> IO (ConnectId self)
    forall obj.
    GObjectClass obj =>
    String -> Bool -> obj -> IO () -> IO (ConnectId obj)
    connect_NONE__NONE String
    "lost_selection")

    -- Boilerplate stolen from gtk to make this library compatible.  These
    -- functions aren't exported at all so I just copied them.

    -- stolen from gtk
    castTo :: (GObjectClass obj, GObjectClass obj') => GType -> String -> (obj -> obj')
    castTo :: forall obj obj'.
    (GObjectClass obj, GObjectClass obj') =>
    CULong -> String -> obj -> obj'
    castTo CULong
    gtype String
    objTypeName obj
    obj =
      case obj -> GObject
    forall o. GObjectClass o => o -> GObject
    toGObject obj
    obj of
        gobj :: GObject
    gobj@(GObject ForeignPtr GObject
    objFPtr)
          | Ptr () -> CULong -> Bool
    typeInstanceIsA ((ForeignPtr () -> Ptr ()
    forall a. ForeignPtr a -> Ptr a
    UF.unsafeForeignPtrToPtr(ForeignPtr () -> Ptr ())
    -> (ForeignPtr GObject -> ForeignPtr ())
    -> ForeignPtr GObject
    -> Ptr ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .ForeignPtr GObject -> ForeignPtr ()
    forall a b. ForeignPtr a -> ForeignPtr b
    castForeignPtr) ForeignPtr GObject
    objFPtr) CULong
    gtype
                      -> GObject -> obj'
    forall o. GObjectClass o => GObject -> o
    unsafeCastGObject GObject
    gobj
          | Bool
    otherwise -> String -> obj'
    forall a. HasCallStack => String -> a
    error (String -> obj') -> String -> obj'
    forall a b. (a -> b) -> a -> b
    $ String
    "Cannot cast object to " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    objTypeName

    connect_OBJECT__NONE ::
      (GObjectClass a', GObjectClass obj) => SignalName ->
      ConnectAfter -> obj ->
      (a' -> IO ()) ->
      IO (ConnectId obj)
    connect_OBJECT__NONE :: forall a' obj.
    (GObjectClass a', GObjectClass obj) =>
    String -> Bool -> obj -> (a' -> IO ()) -> IO (ConnectId obj)
    connect_OBJECT__NONE String
    signal Bool
    after obj
    obj a' -> IO ()
    user =
      String
    -> Bool
    -> obj
    -> (Ptr GObject -> Ptr GObject -> IO ())
    -> IO (ConnectId obj)
    forall obj handler.
    GObjectClass obj =>
    String -> Bool -> obj -> handler -> IO (ConnectId obj)
    connectGeneric String
    signal Bool
    after obj
    obj Ptr GObject -> Ptr GObject -> IO ()
    action
      where action :: Ptr GObject -> Ptr GObject -> IO ()
            action :: Ptr GObject -> Ptr GObject -> IO ()
    action Ptr GObject
    _ Ptr GObject
    obj1 =
              IO () -> IO ()
    forall a. IO a -> IO a
    failOnGError (IO () -> IO ()) -> IO () -> IO ()
    forall a b. (a -> b) -> a -> b
    $
              (ForeignPtr GObject -> GObject, FinalizerPtr GObject)
    -> IO (Ptr GObject) -> IO GObject
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewGObject (ForeignPtr GObject -> GObject
    GObject, FinalizerPtr GObject
    forall a. FinalizerPtr a
    objectUnrefFromMainloop) (Ptr GObject -> IO (Ptr GObject)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Ptr GObject
    obj1) IO GObject -> (GObject -> IO ()) -> IO ()
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \GObject
    obj1' ->
              a' -> IO ()
    user (GObject -> a'
    forall o. GObjectClass o => GObject -> o
    unsafeCastGObject GObject
    obj1')

    connect_NONE__NONE ::
      GObjectClass obj => SignalName ->
      ConnectAfter -> obj ->
      (IO ()) ->
      IO (ConnectId obj)
    connect_NONE__NONE :: forall obj.
    GObjectClass obj =>
    String -> Bool -> obj -> IO () -> IO (ConnectId obj)
    connect_NONE__NONE String
    signal Bool
    after obj
    obj IO ()
    user =
      String
    -> Bool -> obj -> (Ptr GObject -> IO ()) -> IO (ConnectId obj)
    forall obj handler.
    GObjectClass obj =>
    String -> Bool -> obj -> handler -> IO (ConnectId obj)
    connectGeneric String
    signal Bool
    after obj
    obj Ptr GObject -> IO ()
    action
      where action :: Ptr GObject -> IO ()
            action :: Ptr GObject -> IO ()
    action Ptr GObject
    _ =
              IO () -> IO ()
    forall a. IO a -> IO a
    failOnGError (IO () -> IO ()) -> IO () -> IO ()
    forall a b. (a -> b) -> a -> b
    $
              IO ()
    user

    connect_OBJECT_INT64__NONE :: (GObjectClass a', GObjectClass obj)
                                  => SignalName
                                  -> ConnectAfter
                                  -> obj
                                  -> (a' -> Int64 -> IO ())
                                  -> IO (ConnectId obj)
    connect_OBJECT_INT64__NONE :: forall a' obj.
    (GObjectClass a', GObjectClass obj) =>
    String
    -> Bool -> obj -> (a' -> Int64 -> IO ()) -> IO (ConnectId obj)
    connect_OBJECT_INT64__NONE String
    signal Bool
    after obj
    obj a' -> Int64 -> IO ()
    user =
      String
    -> Bool
    -> obj
    -> (Ptr GObject -> Ptr GObject -> Int64 -> IO ())
    -> IO (ConnectId obj)
    forall obj handler.
    GObjectClass obj =>
    String -> Bool -> obj -> handler -> IO (ConnectId obj)
    connectGeneric String
    signal Bool
    after obj
    obj Ptr GObject -> Ptr GObject -> Int64 -> IO ()
    action
      where
        action :: Ptr GObject -> Ptr GObject -> Int64 -> IO ()
        action :: Ptr GObject -> Ptr GObject -> Int64 -> IO ()
    action Ptr GObject
    _ Ptr GObject
    obj1 Int64
    int2 =
          IO () -> IO ()
    forall a. IO a -> IO a
    failOnGError (IO () -> IO ()) -> IO () -> IO ()
    forall a b. (a -> b) -> a -> b
    $ (ForeignPtr GObject -> GObject, FinalizerPtr GObject)
    -> IO (Ptr GObject) -> IO GObject
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewGObject (ForeignPtr GObject -> GObject
    GObject, FinalizerPtr GObject
    forall a. FinalizerPtr a
    objectUnrefFromMainloop) (Ptr GObject -> IO (Ptr GObject)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Ptr GObject
    obj1) IO GObject -> (GObject -> IO ()) -> IO ()
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \GObject
    obj1' ->
            a' -> Int64 -> IO ()
    user (GObject -> a'
    forall o. GObjectClass o => GObject -> o
    unsafeCastGObject GObject
    obj1') Int64
    int2

    connect_OBJECT_STRING_INT64_INT64__NONE :: (GObjectClass a', GObjectClass obj)
                                               => SignalName
                                               -> ConnectAfter
                                               -> obj
                                               -> (a' -> String -> Int64 -> Int64 -> IO ())
                                               -> IO (ConnectId obj)
    connect_OBJECT_STRING_INT64_INT64__NONE :: forall a' obj.
    (GObjectClass a', GObjectClass obj) =>
    String
    -> Bool
    -> obj
    -> (a' -> String -> Int64 -> Int64 -> IO ())
    -> IO (ConnectId obj)
    connect_OBJECT_STRING_INT64_INT64__NONE String
    signal Bool
    after obj
    obj a' -> String -> Int64 -> Int64 -> IO ()
    user =
      String
    -> Bool
    -> obj
    -> (Ptr GObject
        -> Ptr GObject -> Ptr CChar -> Int64 -> Int64 -> IO ())
    -> IO (ConnectId obj)
    forall obj handler.
    GObjectClass obj =>
    String -> Bool -> obj -> handler -> IO (ConnectId obj)
    connectGeneric String
    signal Bool
    after obj
    obj Ptr GObject -> Ptr GObject -> Ptr CChar -> Int64 -> Int64 -> IO ()
    action
      where
        action :: Ptr GObject -> Ptr GObject -> CString -> Int64 -> Int64 -> IO ()
        action :: Ptr GObject -> Ptr GObject -> Ptr CChar -> Int64 -> Int64 -> IO ()
    action Ptr GObject
    _ Ptr GObject
    obj1 Ptr CChar
    str2 Int64
    int3 Int64
    int4 =
          IO () -> IO ()
    forall a. IO a -> IO a
    failOnGError (IO () -> IO ()) -> IO () -> IO ()
    forall a b. (a -> b) -> a -> b
    $ (ForeignPtr GObject -> GObject, FinalizerPtr GObject)
    -> IO (Ptr GObject) -> IO GObject
    forall obj.
    GObjectClass obj =>
    (ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
    makeNewGObject (ForeignPtr GObject -> GObject
    GObject, FinalizerPtr GObject
    forall a. FinalizerPtr a
    objectUnrefFromMainloop) (Ptr GObject -> IO (Ptr GObject)
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Ptr GObject
    obj1) IO GObject -> (GObject -> IO ()) -> IO ()
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \GObject
    obj1' ->
            Ptr CChar -> IO String
    forall s. GlibString s => Ptr CChar -> IO s
    peekUTFString Ptr CChar
    str2 IO String -> (String -> IO ()) -> IO ()
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \String
    str2' ->
              a' -> String -> Int64 -> Int64 -> IO ()
    user (GObject -> a'
    forall o. GObjectClass o => GObject -> o
    unsafeCastGObject GObject
    obj1') String
    str2' Int64
    int3 Int64
    int4